Given that is the correct way to mutate state, why do we need so much
explicit syntax?
user=> (defn += [a b c] (dosync (commute a update-in [b] #(+ c %1))))

user=> (+= player :str 1)
{:str 56}
; are you a giant?

Ok so if I did something like this:
(+= player :int 5)
(+= player :hpmax 10)
in one thread, and on another thread did:
(myset player :int 10)
(myset player :hpmax 88)

The operations might be interleaved whereas it might be desirable to
do the 2 update actions in one transaction to prevent interleaving.
Now this is really up to the programmer as to what is desired, however
a group update is pretty trivial also:
(myset player :int 10 :hpmax 88)

Maybe there is the case where something more complex happens which I
can't imagine and you would still need dosync... but it seems to me
that the majority of occurrences could be hidden away by simple
mutation functions, and these could be written much more generically
than the one above.
Is there an inherent problem with this approach?


Regards,
Tim.

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to