I am stuck on a seemingly basic thing. I have a namespace where I have some definitions:
(ns my-namespace)
(def my-definition "HELLO")
(def my-definition2 "HI")
Now, I want to use the value of the vars in my-namespace
in a macro, but I want to retrieve the symbols dynamically. E.g.,
(defmacro my-macro [n]
(-> "my-namespace/my-definition" symbol resolve var-get))
Retrieving a symbol in such a manner works in a function (as long as the namespace is loaded), but not in a macro.
In a macro, the symbol cannot be resolved. I've tried quoting and unquoting but it still does not work.
Is it possible in a macro to use the value of a symbol created like that? If so, how?
Try this one:
(defmacro my-macro
[str]
(-> str symbol resolve deref))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With