I misspoke; it's the call to counter that's the problem. Let's say you want to use a counter to count the number of times a ref is set, something like this:
(dosync (counter) (ref-set r 1)) If your var-set causes the transaction to retry, an atom-based counter will increment twice. As I understand it, atoms are one of the most "dangerous" things in Clojure, and should be avoided unless you're completely sure it will not change the semantics of your program if it gets executed multiple times. Aside from the memoization example for which it was invented, I am hard-pressed to think of a good use for atoms. For something like a counter, you really have to use ref, and that should remain people's default when dealing with mutability. I haven't done much with atoms yet, so if I've misunderstood Rich's posts, feel free to explain my mistake. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---