On Feb 10, 10:26 pm, Jeffrey Straszheim <straszheimjeff...@gmail.com>
wrote:
> Since we're on the subject, what exactly does ensure *do* that simply
> reading the ref does not?  And then, how does it differ from writing.
>

If you merely read a ref in a transaction that won't prevent another
transaction from changing it. (You won't see that change in your
transaction, of course). If you ensure it, and it is changed by
another transaction, your transaction will retry.

ensure has the rollback-if-modified effects of writing, but differs
from writing in that it doesn't write anything. That matters:

a) for clarity - a fake write to ensure integrity confuses maintainers
b) for concurrency - a fake write looks like a write to other
transactions, and might cause them to roll back.
c) for lack of effects - a fake write might trigger validation or
watch notifications.
d) for some unknown future reason

i.e., I think it is preferable to have an explicit ensure operation
for when that is all that is required, so Clojure's STM has one.

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
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