Read the documentation of commute carefully:
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/commute

commute acts at the end of the current dosync-block, regardless of
when commute was applied inside it. That's the reason why you can't
ref-set it after a commute; the commute isn't done.

On Sun, Jul 25, 2010 at 11:19 AM, dennis <killme2...@gmail.com> wrote:
> Alter or ref-set a ref after commute would throw a
> IllegalStateException:Can't set after commute
>
> for example:
>
> user=> (def counter (ref 0))
> #'user/counter
> (dosync (commute counter inc) (ref-set counter 3))
> java.lang.IllegalStateException: Can't set after commute
> (NO_SOURCE_FILE:0)
>
> I want to know why this should not happen?is it a explanation here? I
> can't understand what is the difference with  commuting ref  after ref-
> set or alter.Thanks a lot.
>
> --
> 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



-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

-- 
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

Reply via email to