I think the answer is in RT 's doInit Var.pushThreadBindings( RT.mapUniqueKeys(CURRENT_NS, CURRENT_NS.deref(), WARN_ON_REFLECTION, WARN_ON_REFLECTION.deref() ,RT.UNCHECKED_MATH, RT.UNCHECKED_MATH.deref()));
it basically does a (binding [*warn-on-reflection* currentvaluehere]) where currentvaluehere is false so it's like: (binding [*my-test1* *my-test1*] (set! *my-test1* true)) basically set! works because you're not seeing the root binding, you're inside a binding already, at least that's what I'm getting out of it. Which leads you to the following: user=> (.start (Thread. (fn [] (do (set! *warn-on-reflection* true) (println "inthread"))))) Exception in thread "Thread-12" java.lang.IllegalStateException: Can't change/establish root binding of: *warn-on-reflection* with set at clojure.lang.Var.set(Var.java:233) at user$eval1176$fn__1177.invoke(NO_SOURCE_FILE:1) at clojure.lang.AFn.run(AFn.java:24) at java.lang.Thread.run(Thread.java:722) nil On Wed, May 15, 2013 at 7:23 PM, Phillip Lord <phillip.l...@newcastle.ac.uk>wrote: > > I'm still a bit confused on the use of set! > > I would like to define a configuration variable that is easy to change, > but which is not critical to my infrastructure; it's will set some > default behaviours. > > Now, I can do things like > > (binding [*warn-on-reflection* true] > (do-some-function)) > > and it does the right thing. Similarly, I can do > > (def ^{:dynamic true} *my-test* false) > (binding [*my-test* true] > (do-some-function)) > > and this all works. > > However, while I can do > > (set! *warn-on-reflection* true) > > I cannot do > > (set! *my-test* true) > > because I cannot change the root binding. What I confused about is how > does this work with *warn-on-reflection*? Where is the root binding? And > how come I am not trying to set it also? Can I get similar behaviour for > one of my vars? Or do I need to do something like: > > (def *my-test* (atom true)) > (reset! *my-test false) > > but then I loose my dynamic binding? > > Phil > > -- > -- > You received this message because you are subscribed to the Google > Groups "Clojure" group. > To post to this group, send email to clojure@googlegroups.com > Note that posts from new members are moderated - please be patient with > your first post. > To unsubscribe from this group, send email to > clojure+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/clojure?hl=en > --- > You received this message because you are subscribed to the Google Groups > "Clojure" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to clojure+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.