Looks like the tradeoffs are composability vs avoiding reflection. I personally would go for the function until performance becomes a concern. Being able to use it in HOFs is a big deal!
On Thursday, July 4, 2013 12:57:32 PM UTC+2, Jim foo.bar wrote: > > (defmacro instantiate > "Returns an instance of the given class. Depending on the argument list will > invoke the corresponding constructor." > [cl-name & args] > `(eval (list 'new ~cl-name ~@args))) > > (defn new-instance "Create a new instance of the specified class using > reflection." > [^Class c & args] > (if (empty? args) (.newInstance c) > (.newInstance > (.getConstructor c (into-array (map class args))) > (to-array args)))) > > > any particular preference? > > Jim > > -- -- 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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.