2010/5/15 islon <islonsche...@gmail.com>: > I'm working in a simple single-thread console-based rpg game in > clojure (a port from my own scala version) > and didn't want to use any concurrency structure because the game is > single threaded. > I was thinking about a macro like > > (defmacro set!! [s val] > `(def ~s ~val)) > > so I can set my game state without using transactions, agents, etc. > Any comments about it?
Hello, It would be like programming C in java (in that you'll get stuff done, but will not have learned a lot 'bout the language/platform you chose for hosting your devs), but if you really want to take this road, then you could use still not try to alter "the whole world" by re-defing things (e.g. altering the root value of your vars). So, you should take a look at: * binding * with-local-vars: http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/with-local-vars * and for mutable effects local to your thread but not limited to the dynamic scope (aka ThreadLocals in java): var-set: http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/var-set HTH, -- Laurent -- 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