Just skimming this on the phone, has no one mentioned RT.map?
On Sep 18, 2011 5:58 PM, "Eamonn" <odon...@gmail.com> wrote:
> Hi Meikel,Ken
> Thank you so much for taking the time to reply to my question. Meikel
> Thanks for the code. I will implement as described above.
>
> On Sep 18, 6:28 pm, Meikel Brandmeyer <m...@kotka.de> wrote:
>> 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

-- 
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