The binding trick seems to work. I had already tried using (in-ns)
before, but didn't realize about needing the binding, so got a nasty
error of course.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group
The ` for ' trick definitely worked. Unfortunately that solves my
example problem but not my real one, since I cant quote the actual
function because its in the form of an incoming stream fed to read. I
looked for some sort of 'qualify-all' function that would act similar
to ` but didnt see one.
You can try the following:
(defn trd[]
(let [f #(binding [*ns* *ns*] (in-ns 'user) (eval '(tst)))]
(. (Thread. f) start) ))
This sets the namespace for your new thread before it evals. You also
might want to take a look at clojure.lang.Repl for an example of how
to create a REPL, also repl
Hello,
Am 08.09.2008 um 20:37 schrieb noahr:
(defn tst[] (pr 4))
(defn trd[]
(let [f #(eval '(tst))]
(. (Thread. f) start) ))
The eval executes the code in the clojure namespace. You have to fully
qualify your tst function. The easiest way to do this to use ` instead
of '. So using `
I've hit another mystery (to me), that I hope someone can explain.
Why doesn't the following work?
(defn tst[] (pr 4))
(defn trd[]
(let [f #(eval '(tst))]
(. (Thread. f) start) ))
It seems that a separate thread can not EVAL any defined functions. If
I change the above to remove the thr