I don't know much about functional programming, but I believe you're supposed to think about functions as black boxes. Put something in, get something out.
Take this function, for example: (defn snake-head [] (first (@snake :body))) (We're cheating on the put something in part!) Perhaps it'd be better if we didn't instantiate the snake until later in the "game loop." What if we wanted to make a game with two snakes? Then snake-head is broken. Rather, we just do something like: (defn snake-head [any-snake] (first (@any-snake :body))) Now many snakes from many threads can use this function. (I think.. I'm noobs, so... :) In fact, in most game tutorials, the "game loop" will be in a separate thread all together, so it might be more common to leave any def'ing of apples and snakes toward the bottom, where you have the gui code. As a side note, if I remember correctly, other Java game tutorials usually frame up the gui fairly early in the code. They probably do that for aesthetic reasons -- so the Java app seems to load faster. Don't quote me on that though. 2cents On Fri, Jan 2, 2009 at 8:39 PM, Mark Volkmann <r.mark.volkm...@gmail.com>wrote: > > For anyone still following this, the latest code that incorporates > many of the suggestions I've received here is at > http://www.ociweb.com/mark/programming/ClojureSnake.html, replacing my > original version. It now uses refs. I think I have the dosyncs > optimally placed. Feedback still welcomed! Can I / should I further > reduce the number of defs I have? > > -- > R. Mark Volkmann > Object Computing, Inc. > > > > -- John --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---