On 21 February 2010 14:13, Michael Wood <esiot...@gmail.com> wrote: > That does demonstrate the difference (or a difference), but I don't > get 3 printlns.
Ouch, I actually posted the wrong version of the function. Here's an improvement in the context of a REPL interaction: 1. ensure version: user> (defn funk [r] (dosync (println (ensure r)) (Thread/sleep 5000) (println (ensure r)))) #'user/funk user> (def r (ref 1)) #'user/r user> (.start (Thread. #(funk r))) 1 nil user> (dosync (ref-set r 5)) 1 5 2. deref version: user> (defn funk [r] (dosync (println @r) (Thread/sleep 5000) (println @r))) #'user/funk user> (def r (ref 1)) #'user/r user> (.start (Thread. #(funk r))) 1 nil user> (dosync (ref-set r 5)) 5 5 5 Note how the deref version prints more lines (because it retries the transaction). I'm using a newer commit (49a7d6b8e14050a45df5332e768ba6647752215d), but this shouldn't make any difference. Sincerely, Michał -- 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