According to spec, def
should intern the var in the current ns (i.e. *ns*). However, the following code does not look anything like it:
(ns namespace-b)
(defn def_something []
(ns namespace-a)
(println *ns*) ;prints namespace-a as it should
(def something 1)
)
(def_something)
(println namespace-b/something) ; prints 1
(println namespace-a/something) ; throws
What am I missing?
Notes:
defn
is used just for clarity. Defining and running anonymous function works just as well.- I know that using
def
inside function is probably not very idiomatic. However, this is just extracted essence of a bigger problem I ran into.