I want to achieve to return a namespace resolved symbol in a macro that has recently defined the symbol itself:
(ns my-namespace)
(defmacro def&resolve [a b]
`(do
(def ~a 12)
(def ~b ~(resolve a))))
(def&resolve foo bar)
bar ;=> nil
In the example bar
returns nil. I however, want it to return my-namespace.foo
. I know this is not working since at the time resolve
is called, a
isn't defined yet. I need a
to be namespace-resolved at macro-expansion time for my use case [1], however.
In the next run I wanted to declare a
at macro expansion time (does that even make sense?) and, thus, force that it is present in the current ns when calling resolve
.
(defmacro def&resolve [a b]
(declare a)
`(do (def ~a 12)
(def ~b ~(resolve a))))
(def&resolve foo bar)
bar ;=> nil
Doesn't work either.
How can I def something and at the very macro expansion namespace resolve it?
[1] My use case is the following: I want to define a bundle of functions and add it to the meta information of a def-binding (thus, I need it at macro expansion time). Currently, I only store the symbols, without the namespace the functions were defined in.