Problem expanding macro in clojure
I have a clojure macro:
(defmacro show
[x] `(show-fn ~x)
)
: whi开发者_运维技巧ch given :
(show hello)
I want to resolve to :
(show-fn 'hello)
: How can I do this?
user=> (defmacro show [x] `(~'show-fn '~x))
#'user/show
user=> (macroexpand '(show hello))
(show-fn (quote hello))
This is called 'symbol capture'. It keeps the symbol from being resolved in the current namespace, as with your example.
精彩评论