Thank you very much for the quick answer. That makes a lot of sense. If there were no return value, there would be a need to throw exception on subsequent reads. You're right, that would add a lot of complexity.
I wanted that because I have a bunch of set updates (insertions) in a transaction and don't care about the result in a quite long transaction. Is putting every update in a seq that I execute by itering alter just before the end of transaction a good way for doing that? On 5/4/10, Rich Hickey <richhic...@gmail.com> wrote: > > On May 4, 2010, at 9:30 AM, Nicolas Oury wrote: > >> Dear all, >> >> Is there an equivalent of commute without return value? >> >> A part of the usage of commute just want to change something without >> knowing the result. >> (For example, I want to extend a set). >> >> I know it is not very expensive but computing twice a function - if >> there is a bit of contention, but else why bother with commute? - for >> nothing is a bit sad :(. >> >> Moreover, without return value, it would be possible to ensure that >> each commute function is called at most once per transaction. >> >> >> Or I don't understand commute at all? >> > > The reason commute does the work when called is that you might have > code further on in your transaction that needs to see the work of the > transaction thus far, i.e. that the set contains the things you've > added, or that a counter is non-zero. Even if those values aren't the > final ones after the transaction they in some sense include the work > thus far. Note that this isn't just about the return value. Otherwise, > you might deref a ref you have commuted and not see your own work, > which seems wrong to me. There could of course be two versions of > commute, but it adds complexity. > > Rich > > -- > 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 -- 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