2010/3/14 Meikel Brandmeyer <m...@kotka.de>

> In short: ensure is used when you require only read access to a Ref,
> but need the value to be constant through the transaction. If you
> modify the a Ref via alter or ref-set, the ensure is not necessary.
>
>
OK, I think I've finally figured out why I've always found ensure to be a
bit confusing.  I often see ensure described like you did above, that you
use it if you "need the value to be constant through the transaction."  I
was puzzled, because I thought you were already guaranteed that the value is
constant by the semantics promised by the STM system, "All reads of Refs
will see a consistent snapshot of the 'Ref world' as of the starting point
of the transaction (its 'read point')."

So what I'm finally realizing is that although you are guaranteed a
consistent read value throughout the transaction, that value might become
out of touch with "reality" unless you use ensure.

So I think I get it now, although Michal's examples make no sense to me, so
maybe I'm still missing something.

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