The point, for me, is that Mark Engelberg's construct allowed the system to
work with no mutation and I don't think you can do it with Swing implemented
the way it is (your latest version puts the mutation in an atom).

Given that, and the problems with to threads accessing the Swing layer, I
think living in the EDT makes the most sense.  For example the "everything
in the EDT" approach takes advantage of Swing's painting features and deals
with multiple events while cleanly painting the board; the two thread
approach flickers terribly when the snake is short.

Rgds.

Tom


2009/1/8 Mark Volkmann <r.mark.volkm...@gmail.com>

>
> On Thu, Jan 8, 2009 at 5:08 AM, Tom Ayerst <tom.aye...@gmail.com> wrote:
> >
> > Using loop - recur means there are now two threads in the code (The app
> loop
> > and Swing event loop) and these must be coordinated.  This is, I think,
>  why
> > Mark needed that last global and Stuart didn't.
>
> My latest code no longer has any globals. See the atom named key-code-atom
> at
> http://www.ociweb.com/mark/programming/ClojureSnake.html.
>
> > I don't think there is a way to do this without some mutation because of
> the
> > implementation of Swing, but, as I said, I may be wrong.  There will need
> to
> > be at least one concurrency construct.
>
> The code at that URL does work. I haven't been able to think of a
> scenario where it might fail, despite the fact that I'm painting
> outside the event dispatch thread (EDT). However, if there's a better
> way to do this, I'm all ears!
>

--~--~---------~--~----~------------~-------~--~----~
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
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to