Hi Eamonn,

if you find this too tedious to write and use it quite often, then there is 
always the possibility to hide things a little bit behind a facade.

class Clj {
    static final Var seqVar = RT.var("clojure.core", "seq");
    static final Var keywordVar = RT.var("clojure.core", "keyword");
    static final Var hashMapVar = RT.var("clojure.core", "hash-map");

    static Object seq(Object x) { return seqVar.invoke(x); }
    static Object kw(String n) { return keywordVar.invoke(n); }
    static Object kw(String n1, String n2) { return keywordVar.invoke(n1, n2); }
    static Object hashMap(Object... args) { return 
hashMapVar.applyTo((clojure.lang.ISeq)seq(args)); }
}

This would make names a little bit more meaningful (less “invoke”s) for the 
functions you use most. And you might use your own function names. Of course 
this won't reach the sugar you get from Clojure itself.

theMap = Clj.hashMap(Clj.kw("a"), 1, Clj.kw("b"), 2);
foo.invoke(Clj.kw("a"), theMap);

This translates directly into:

(let [the-map (hash-map :a 1 :b 2)]
  (foo :a the-map))

It should be easy to understand what's going on despite the noise. I believe 
Java devs are used to noise.

And FWIW: Not quoting "13rabc" by accident in the other scenario will not 
result in the Reader complaining but puzzled looks where this magical value 
came from. I personally don't particular like these moments.

My 0,02€. YMMV.

Sincerely
Meikel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to