Thanks for your reply,Ulrich I knew that comute would rerun before the commit,but my problem is that if we allow ref-set ref after commuting,it seems there is no bad thing would happen.What's the purpose of this limitation except alter or ref-set have no lasting result?
On Jul 25, 7:01 pm, Moritz Ulrich <ulrich.mor...@googlemail.com> wrote: > Read the documentation of commute > carefully:http://richhickey.github.com/clojure/clojure.core-api.html#clojure.co... > > 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