On Sat, Feb 5, 2011 at 1:01 AM, Alan <a...@malloys.org> wrote:
> That's not how macros work. They can only operate on the parameters
> they're passed, as symbols and lists.

Clojure macros can also see literal maps, sets, and vectors, not to
mention integers, strings, and the like. (Ever seen
"IllegalArgumentException: let requires a vector for its binding" or
similarly?)

user=> (defmacro foo [x] `(println ~x "was a" ~(type x)))
#'user/foo
user=> (def a 42)
#'user/a
user=> (foo [])
[] was a clojure.lang.PersistentVector
nil
user=> (foo #{})
#{} was a clojure.lang.PersistentHashSet
nil
user=> (foo {})
{} was a clojure.lang.PersistentArrayMap
nil
user=> (foo a)
42 was a clojure.lang.Symbol
nil
user=> (foo 42)
42 was a java.lang.Integer
nil
user=> (foo "bar")
bar was a java.lang.String
nil

-- 
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