w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Executing code in another Clojure namespace, why is eval required?

Setting ns with bind doesn't quite work that way, which is why the doc's for namespaces include this warning:

"The current namespace, *ns* can and should be set only with a
call to in-ns or the ns macro, both of which create the namespace if it
doesn't exist."

In your example the symbol xx is being resolved in the namespace user instead of the namespace that *ns*is bound to:

user> (defn xx [a b] "I'm the xx from ns user")
#'user/xx
user> (wns 'boofar (println *ns*) (xx 5 6))
#<Namespace boofar>
"I'm the xx from ns user"




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.