On Wed, Nov 26, 2008 at 1:13 PM, Shawn Hoover <[EMAIL PROTECTED]> wrote:
>
>
> On Wed, Nov 26, 2008 at 1:55 PM, Mark Volkmann <[EMAIL PROTECTED]>
> wrote:
>>
>> The documentation for commute says "Sets the in-transaction-value of
>> ref ...". This implies to me that when the transaction ends, the ref
>> will have its previous value.
>>
>> (def myRef (ref 19))
>> (dosync (commute myRef inc)) -> 20
>> @myRef -> 20
>>
>> Why isn't the value of the last line 19?
>>
>> --
>> R. Mark Volkmann
>> Object Computing, Inc.
>
> "in-transaction" just means that the new value is seen if code later in the
> transaction dereferences myRef, while the rest of the program (other
> threads) will not see the new value until the transaction succeeds. Once the
> transaction commits, then the rest of the program will also see the new
> value. If you need something that takes on a new value within a defined
> scope and then pops off to the previous value, check out Vars and binding.

Is that the main difference between commute and set-ref?
commute sets a value that isn't seen outside the transaction until the
transaction ends.
set-ref sets a value that is immediately seen outside the transaction
before it ends.

-- 
R. Mark Volkmann
Object Computing, Inc.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to