On 6 September 2010 01:11, ingokr <ing...@gmail.com> wrote: > Patrick & Meikel: thanks! Your solutions do produce almost what I > need; the idea is with > > (tm a b) > > I should get back > > {:a a :b b} > > Your solutions produce sth equivalent to {:a (eval a) :b (eval b)} in > this case.
Actually Meikel's solution does exactly what you want: user> (macroexpand '(tm a b)) {:a a, :b b} Of course if you simply write (tm a b) at the REPL, then the result of the macroexpansion will be immediately evaluated. It still won't be equivalent to {:a (eval a) :b (eval b)}, though, because the values for 'a and 'b might come from local bindings, whereas with eval they'd need to come from the "global environment" (the current namespace). Patrick's solution is different, because it delays the construction of the hash map to runtime, plus the arguments get evaluated prior to hash-map being called (you'd have to use something like (map (fn [arg] `'~arg) args) in place of args to avoid that). Sincerely, Michał -- 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