I can load an arbitrary source of Clojure using:
(load-string source)
However, if a namespace was not provided, it loads the code into the namespace clojure.core.
For example, the following code:
(load-string "(defn add [a b] (+ a b))")
defines a function:
#'clojure.core/add
Now, is there a way to load this code into another namespace, preferably the same one in which the function is called load-string?
(Besides preceding the declaration of the namespace before the string sourcebefore evaluating. I know this will solve the problem - I would like to know if there is a preferred way)
source
share