If you macroexpand the first foo in (foo 1 2), you will see something like
(1 2)

when this gets evaluated, Clojure is not happy about 1 not being a function.

On Wed, Jul 7, 2010 at 5: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)
>
> 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)
>
> I have tried this on todays (July 7) bleeding edge and 1.1 with the
> same results.
>
> --
> 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<clojure%2bunsubscr...@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 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

Reply via email to