n Fri, Jan 2, 2009 at 4:47 PM, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: > > On Fri, Jan 2, 2009 at 3:09 PM, Chouser <chou...@gmail.com> wrote: >> >> On Fri, Jan 2, 2009 at 4:05 PM, Tom Ayerst <tom.aye...@gmail.com> wrote: >>> That def inside a function doesn't look right but I'm a noob at this too. I >>> managed to run the snake off the board which suggests the concurrency is not >>> quite right. >> >> Calling 'def' to like this is much worse than a lack of comments, >> especially in code meant to teach. > > Thanks for the feedback! I'll gladly change it to use atoms or agents > or refs. I'm just not sure which one is most appropriate. What do you > think I should use?
I don't feel I have much authority in the realm of designing concurrent programs, but here are a couple thoughts: It seems to me that 'apple' and 'snake' together describe the state of the game, and therefore need their changes coordinated. This suggests they should both be refs. I think it might also be very natural to use a single agent with Thread/sleep and send-off to itself instead of the Timer. This would detangle the actionPerformed method from the panel, and allow you to give the action function a meaningful name instead. --Chouser --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---