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.awt.event ActionListener))
(def *value* 'ok)
(defn test-eval []
(load-file "dyn.clj"))
(let [frame (JFrame.)
button (JButton. "Click Me")]
;; this gets exception "Unable to resolve symbol: *value*
(.addActionListener
button
(proxy [ActionListener] [] (actionPerformed [evt] (test-eval))))
(doto frame
(.add button)
(.pack)
(.show)))
What's happening in the ActionListener code?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---