Strange behaviour of keywords within macros in Clojure
Posted
by mikera
on Stack Overflow
See other posts from Stack Overflow
or by mikera
Published on 2010-05-19T19:19:43Z
Indexed on
2010/05/19
19:20 UTC
Read the original article
Hit count: 239
I'm a little confused by how keyword accesses seem to behave in Clojure when they are evaluated at macro expansion time.
The following works as I expect:
(def m {:a 1})
(:a m)
=> 1
However the same keyword access doesn't seem to work within a macro:
(def m {:a 1})
(defmacro get-a [x] (:a x))
(get-a m)
=> nil
Any idea what is going on here?
© Stack Overflow or respective owner