Why does the Snake example in the book use refs when all mutation is done from the EDT?
To verify that, I put a call to "assert-edt" in front of every dosync in snake.clj. assert-edt is defined like this: (defn assert-edt [] (assert (javax.swing.SwingUtilities/ isEventDispatchThread))) And it never throws. So why would I use transactions when Swing is already taking care of everything? The only reason I see is when you also want to mutate things for testing in the REPL. But even in that case, you could still do (javax.swing.SwingUtilities/invokeAndWait #(mutate-like-crazy)) Second question - in the functional section of snake.clj, there is this function: (defn point-to-screen-rect [pt] (map #(* point-size %) [(pt 0) (pt 1) 1 1])) Is it considered functional (=pure?) because point-size is considered to be constant? According to the definitions of pure/functional that I've come across (return value only depends on function parameters, has no side effects) it would not be pure, as point-size can be changed, affecting the operation of that function. But then again in the face of dynamic rebinding (I could even rebind map to do something completely different), is there anything pure in clojure at all? And while I (still) got your attention ;), dynamic rebinding of macros is impossible because all references to macros disappear in the compilation phase, correct? Otherwise I could have just rebound dosync to always call assert-edt first instead of putting it in front of every "call" to dosync. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---