On 03/24/2011 05:40 PM, Meikel Brandmeyer wrote:
The problem is the constructor call. With plain old clojure functions you could use apply, but Java method and constructor calls must be hard-wired in the bytecode (and hence at compilation time) (if I understood this correctly).
Guess that's why a macro, which I tried out of sheer curiosity, doesn't work, either.
So there will be now way around explicitly specifying the map keys. Although you can relieve the pain a little with destructuring as Tassilo already showed. It can be shorted a bit using :strs. (defn save-article [path {:strs [title body]} timestamp] (ds/save! (Article. path title body timestamp)))
I had been using destructuring, just not in the example, where I had to have a whole form-params. :strs makes that quite a bit nicer, thanks!
Looking for a bit more info, I found: http://groups.google.com/group/clojure/browse_thread/thread/a9504c4c9b1a4d9b explaining :strs, :keys and :syms. -- Thorsten Wilms thorwil's design for free software: http://thorwil.wordpress.com/ -- 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