On Wed, Jul 7, 2010 at 12:49 PM, Cameron <cpuls...@gmail.com> wrote: > Hello all! Today, I've either discovered a bug, or I've discovered a > flaw in my understanding of macros. Most likely the latter :-) Could > anyone set me straight? > > While this is not the macro I was trying to write, it falls over in > the same place. > > (user=> (defmacro foo [& xs] `(map identity ~xs)) > #'user/foo > user=> (foo 1 2)
java.lang.ClassCastException: java.lang.Integer cannot be cast to > clojure.lang.IFn (NO_SOURCE_FILE:0) > You're splicing in the list (1 2). 1 is not function, thus the error. > However, this does work (though it doesn't feel idiomatic). > > user=> (defmacro foo [& xs] `(map identity [...@xs])) > #'user/foo > user=> (foo 1 2) > (1 2) > Looks pretty idiomatic to me :) -- 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