Re: variable scope in an event handler

2008-12-27 Thread .Bill Smith
> ... in any case > explicitly setting *ns* works, and really who uses eval/load-file like > this?? Agreed. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to

Re: variable scope in an event handler

2008-12-27 Thread Timothy Pratley
Just a simpler example to demonstrate that new threads have *ns* set to clojure.core: (def *value* 'ok) (def *a* (agent nil)) (send *a* (fn f [x] (println "AGENT:" *ns*))) (send *a* (fn f [x] (eval '(println "AGENT:" *value* (try (await *a*) (catch Exception e (println e) (println (agent-erro

Re: variable scope in an event handler

2008-12-27 Thread Timothy Pratley
Ah thanks Bill well that would explain it! I added (println "DYN:" *ns*) to dyn.clj and (println "DEF:" *ns*) to def.clj and this is what I get: >From the command line: C:\java>clj def.clj DEF: # DYN: # ok >> both are in the same namespace >From the REPL: C:\java>clj Clojure user=> (load-file "d

Re: variable scope in an event handler

2008-12-27 Thread Timothy Pratley
> What's happening in the ActionListener code? Actually this is more a question of how does load-file work I believe. If I run your example with (read) added to the end to prevent the main thread ending from the command line: clj test.clj it works as expected... ie: ok gets printed when clicking

Re: variable scope in an event handler

2008-12-27 Thread .Bill Smith
I suggest you start by comparing the current namespace in your actionPerformed method with that of *value*. Perhaps they are different. Bill --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post t

variable scope in an event handler

2008-12-27 Thread what-a-guy
Here's some code that works as I expected: dyn.clj (println *value*) test.clj (def *value* 'ok) (defn test-eval [] (load-file "dyn.clj")) (test-eval) => 'ok But when run in an event handler it fails: test.clj (import '(javax.swing JButton JFrame) '(java.aw