On 15 March 2010 08:07, Mark Engelberg <[email protected]> wrote: > 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.
That's not true actually. For example: user> (def r (ref 0)) #'user/r user> (future (println @r) (Thread/sleep 5000) (println @r)) 0 #<core$future_call$reify__6...@1aa5f9b: :pending> user> (dosync (ref-set r 5)) 5 5 Note that you have to type in the dosync before the future thread wakes up. > So I think I get it now, although Michal's examples make no sense to me, so > maybe I'm still missing something. One thing which may not be clear at a glance is that things are happening on multiple threads and in the ensure version, the final dosync blocks. Try it out at the REPL to see what I mean. Sincerely, Michał -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to [email protected] Note that posts from new members are moderated - please be patient with your first post. 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
