Never mind my previous post. I realized my problem doesn't have
anything to do with threads at all. What I'm really asking is: Is it
possible for a closures to automatically capture a dynamic variable?
ie. The following doesn't work as you expect:
(def env)
(defn create-fn []
(fn [] (println env)))
(binding [env "environment 1"]
(def fn-a (create-fn))) <-- create a "environment 1" function
(binding [env "environment 2"]
(def fn-b (create-fn))) <-- create a "environment 2" function
You must first capture the dynamic var in a let, and then capture the
let var in a closure
(defn create-fn []
(let [env env] <-- Capture dynamic var in a let
(fn [] (println env))))
Thanks for reading.
-Patrick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---