I try to write a macro in clojure that sets up a namespace and automatically adds a few methods to it. My macro wasn't working and I tracked it down to a do statement. It is not possible to declare a new namespace in a do and immediately afterwards declare a method in that namespace. Why?
This does not work:
(ns xyz)
(do
(ns abc)
(prn *ns*)
(defn tst[] (prn "test" *ns*)))
(prn "after" *ns*)
(tst)
This works (namespace declaration before the do):
(ns xyz)
(ns abc)
(do
(prn *ns*)
(defn tst[] (prn "test" *ns*)))
(prn "after" *ns*)
(tst)
Thanks for reading, Markus