The example demonstrates that your interpretation is exactly what occurs,
as described in CFB&T.  It is just not what I thought was happening from
reading all of the other Clojure books!
Alan

On Tue, Nov 3, 2015 at 10:00 PM, Sean Corfield <s...@corfield.org> wrote:

>
> So, when using commute the update function is ALWAYS run TWICE!  Holey
> Bovine, Batman!
>
>
> The docs for commute say:
>
> clojure.core/commute
>
> ([ref fun & args])
>
>   Must be called in a transaction. Sets the in-transaction-value of
>
>   ref to:
>
>
>   (apply fun in-transaction-value-of-ref args)
>
>
>   and returns the in-transaction-value of ref.
>
>
>   At the commit point of the transaction, sets the value of ref to be:
>
>
>   (apply fun most-recently-committed-value-of-ref args)
>
>
>   Thus fun should be commutative, or, failing that, you must accept
>
>   last-one-in-wins behavior.  commute allows for more concurrency than
>
>   ref-set.
>
> That seems to indicate that fun will be called twice: once to set the
> *in-transaction-value* of the ref and a second time at the commit point.
> Or am I misreading the docstring?
>
> Sean
>
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to