On Sat, Jun 29, 2013 at 8:21 PM, Ben Wolfson <wolf...@gmail.com> wrote:
> On Sat, Jun 29, 2013 at 5:07 PM, Brandon Bloom > <brandon.d.bl...@gmail.com>wrote: > >> > Can anyone explain the relationship between swap! and reset! ? >> >> swap! is for "CAS" >> >> See: http://en.wikipedia.org/wiki/Compare-and-swap >> >> > How so? No comparison is done (unless it's done in the supplied function, > which is entirely up to the user of swap!). There's a separate > compare-and-set! function for atoms. > Er, swap! is basically (loop [] (let [x @a y (f x)] (if (compare-and-set! a x y) y (recur)))) though it actually calls a .swap method of the Atom object that has equivalent semantics. -- -- 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 --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.