Let's say I create a variable, x
, in a Clojure namespace, store the associated var in another variable (y
), and then unmap x
:
(ns user)
(def x 0)
(def y (var x))
(ns-unmap 'user 'x)
If I evaluate y
in the REPL, it prints #'user/x
, even though the symbol user/x
is not associated with this variable anymore.
user=> y
#'user/x
user=> (deref y)
0
user=> (deref #'user/x)
Syntax error compiling var at (REPL:0:0).
Unable to resolve var: user/x in this context
Things get really confusing if I create a new variable associated with the symbol x
:
(def x 1)
(def z (var x))
Now, the repl prints both y
and z
as #'user/x
, even though those variables point to different var objects:
user=> y
#'user/x
user=> (deref y)
0
user=> z
#'user/x
user=> (deref z)
1
user=> (= z y)
false
Why does the REPL print #'user/x
when evaluating y
here?