"load" is a low-level file loading function; it does not reload dependent namespaces.
Use the higher-level "require" and "use" functions with the :reload- all option, which will reload dependent namespaces. -SS On Aug 23, 2:48 pm, Conrad <drc...@gmail.com> wrote: > Hi- I have a bug in my code related most likely to my misunderstanding > of some arcane corner of Clojure namespaces... can someone tell me > what I'm missing? > > First, create the following 2 files: > > --- foo.clj --- > (ns foo) > (def x (ref true)) > --- end foo.clj --- > > --- bar.clj --- > (ns bar > (:use foo)) > (defn change-x [] > (dosync (ref-set x false))) > --- end bar.clj --- > > Now, run the following from the REPL: > > user=> (load "bar") > user=> (in-ns 'bar) > bar=> x > #<r...@15291cd: true> > bar=> (change-x) > #<r...@15291cd: false> > bar=> x > #<r...@15291cd: false> > bar=> (load "bar") > bar=> x > #<r...@15291cd: false> > > As you can see, the value of x remains false, despite the fact that I > reloaded the file... can someone explain to me why reloading the code > doesn't cause the variable x to be redefined back to true? It seems if > variables in "used" files aren't re-def'ed then you can't properly re- > load your code if you have multiple namespaces... > > Thanks! > Conrad Barski --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---