Awesome! Works great! (After fixing the typo in "SwingUtilites". that
is :)
--~--~-~--~~~---~--~~
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
Here is a debugged version:
(in-ns 'clojure.core)
(let [old-dosync-fn @#'dosync]
(defmacro dosync [& body]
(let [real-dosync-job (apply old-dosync-fn body)]
`(do
(assert (javax.swing.SwingUtilites/isEventDispatchThread))
~real-dosync-job
HTH,
--
Laurent
2009/7/
On Fri, Jul 10, 2009 at 3:44 PM, Rowdy Rednose wrote:
>
> On Jul 10, 10:28 pm, Stuart Halloway
> wrote:
> You can rebind macros, but in order to use them you have to compile
> > some code again.
>
> Recompiling would be fine in this case, but how can I rebind macros?
eval is evil but...
(let
I think you'll have to retrieve the old dosync corresponding function, and
call this function to get the corresponding generated code, and insert this
code at the correct place.
Note also that I would better use (in-ns 'clojure.core) instead of (ns
clojure.core) (ns is reserved for the creation of
2009/7/10 Rowdy Rednose :
>
> The idea is to have all existing code (that gets recompiled after my
> redefinition) benefit from my changes automatically, although I fear
> it's not considered good style to do this.
Ah. Well, I've just tried:
(in-ns 'clojure.core)
(def old-dosync dosync)
but it
The idea is to have all existing code (that gets recompiled after my
redefinition) benefit from my changes automatically, although I fear
it's not considered good style to do this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Go
2009/7/10 Michael Wood :
> 2009/7/10 Rowdy Rednose :
>>
>> Actually, it didn't work (apart from having a "not" in there, which I
>> only used for testing).
>>
>> Calling sync directly works, though:
>>
>> (ns clojure.core)
>> (defmacro dosync [& body]
>> `(do
>> (assert (javax.swing.SwingUtil
2009/7/10 Rowdy Rednose :
>
> Actually, it didn't work (apart from having a "not" in there, which I
> only used for testing).
>
> Calling sync directly works, though:
>
> (ns clojure.core)
> (defmacro dosync [& body]
> `(do
> (assert (javax.swing.SwingUtilities/isEventDispatchThread))
> (
Actually, it didn't work (apart from having a "not" in there, which I
only used for testing).
Calling sync directly works, though:
(ns clojure.core)
(defmacro dosync [& body]
`(do
(assert (javax.swing.SwingUtilities/isEventDispatchThread))
(sync nil ~...@body)))
But can't I somehow
This did the trick:
(ns clojure.core)
(defmacro dosync [& body]
`(do
(assert (not (javax.swing.SwingUtilities/isEventDispatchThread)))
(#'dosync ~...@body)))
This is great for testing!
Thanks for your help, Stu. And btw the book is really great so far
(and I'm almost through)! It pr
To rebind a macro in clojure.core you would need to first enter that
namespace:
(in-ns 'clojure.core)
Or, create your own dosync in a different namespace which explicitly
does not refer to clojure.core/dosync. See the docstring for
clojure.core/ns for using :exclude.
Stuart
>
> On Jul 10
On Jul 10, 10:28 pm, Stuart Halloway
wrote:
> binding to a thread. The snake game could be extended to be a
> simulation that runs on multiple threads (or perhaps even multiple
Makes sense. For the example in the book it just seemed completely
redundant. And when writing Swing code, at least
Hi Rowdy,
The snake uses refs because idiomatic Clojure code should not require
binding to a thread. The snake game could be extended to be a
simulation that runs on multiple threads (or perhaps even multiple
machines) without having to change the basic code. Normally, you
wouldn't build
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 n
14 matches
Mail list logo