Hi, just for practicing Clojure's macros I wrote the following create-java-list macro.
(defmacro create-java-list [& forms] (let [prefixfn (fn [obj form] (cons (symbol ".") (cons obj form))) lname (gensym)] `(let [~lname (java.util.ArrayList.)] ~@(map (partial prefixfn lname) forms) ~lname))) The idea is that you can write (let [javalist (create-java-list (add "1") (add "2"))] (prn javalist)) instead of (let [javalist (java.util.ArrayList.)] (.add javalist "1") (.add javalist "2") (prn javalist)) Is it possible to create the macro without the (gensym) call? I wasn't able to use something like lname#. Cheers, Roman -- 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