So I noticed some curious behaviour:
(defmacro foo [body] {:env &env :form &form :body body})
=> #'user/foo
(#'user/foo :body)
=> java.lang.IllegalArgumentException: Wrong number of args (1)
passed to: user$foo (NO_SOURCE_FILE:0)
(#'user/foo :form :env :body)
=> {:env :env, :form :form, :body :body}
(#'user/foo :form :env body)
=> Unable to resolve symbol: body in this context
So it appears when you call a macro by its var, it acts just like a
function, even though its metadata says it should be a macro.
(:macro (meta #'foo))
=> true
I suspect the answer may just be "yeah... that's not something you
should do with macros", but I'm curious. I suppose the compiler only
checks the :macro metadata when it's literally in the call position
rather than when there's indirection through calling var?
-Phil
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en