> The problem with identities of actors comes in when you consider code > like the following: > > (def trantor (get-actor "Trantor" world-state)) > > (:hit-points trantor) > => 10 > > (def new-world-state ((command "Trantor" :eat "apple") world-state)) > > (:hit-points trantor) > => 10 (still!! because we took a snapshot of trantor......) > > (def new-trantor (get-actor "Trantor" new-world-state)) > > (:hit-points new-trantor) > => 15 > > Maybe this is all fine and I'm sure it is possible to successfully > write a game this way. However it does feel a little strange when you > are coming from OOP languages where you are used to simulating > everything with mutable state....
I think that's the issue. Expecting your def-ed trantor to change once the world state has been updated is what would be expected in a world of pointers, OOP, etc. However, the new updated world (in my view) has a new trantor which you need to extract with your (get-actor ...). This would all seem reasonable to me (modulo performance of updating the world, etc.) since then you have many functions operating on a single data structure and your flow is in terms of these functions only. Cheers, U -- 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