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

Reply via email to