Thanks for all the replies everyone, I certainly have a solution now.
But I am still a little confused. Take this slight variation...

user=> (defmacro foo [coll] `(map identity ~coll))
#'user/foo
user=> (foo [1 2 3 `(+ 1 1)])
(1 2 3 (clojure.core/+ 1 1))

In this one, I am passing an explicit list and simply calling unquote
on it. I guess what I want to know is, how is passing an explicit list
different from having one destructured with '&' in the arguments
list?


On Jul 7, 1:04 pm, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> Of course I meant
> (map identity (1 2))
>
>
>
> On Wed, Jul 7, 2010 at 6:03 PM, Nicolas Oury <nicolas.o...@gmail.com> wrote:
> > 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