I can load arbitrary Clojure source using:
(load-string source)
However, if namespace wasn't provided, it loads code to clojure.core
namespace.
For example, following code:
(load-string "(defn add [a b] (+ a b))")
defines a function:
#'clojure.core/add
Now, is there a way to load that code to some other namespace, preferably the same one in which load-string
function is called?
(Other than prepending a namespace declaration to source
string before evaluation. I know that it would solve the problem - I'd like to know is there a preferred way)