4 ms·
Oh yes, that's a Clojure atom. Been there, done that. https://www.braveclojure.com/zombie-metaphysics/ https://www.braveclojure.com/zombie-metaphysics/ (BTW,
by kimi 7y ago
Oh yes, that's a Clojure atom. Been there, done that. https://www.braveclojure.com/zombie-metaphysics/ https://www.braveclojure.com/zombie-metaphysics/
(BTW, in practice, Clojure atoms were initially thought of as the simple case of refs, where you have a full STM behind you. In practice, atoms end up being "good enough" in nearly all cases....)
- dwohnitmok 7y agoI think (?) the difference between this and an atomic reference (of which a Clojure atom is a specific example) is that it is geared towards mutable data structures rather than immutable ones. Although as far as I can tell it's more or less emulating immutable data structures by copying the mutable data structure before modification. As for the ultimate lack of widespread use of STM in real-world Clojure code, I think in addition to the nice interface provided by atoms, it's also in part because Clojure's STM lacks a couple of combinators that limit its composability, and so a lot of other concurrency approaches make more sense. See the combinators provided by https://github.com/skejserjensen/eclojure https://github.com/skejserjensen/eclojure and http://www.thattommyhall.com/2013/02/15/stm-clj-vs-haskell/ http://www.thattommyhall.com/2013/02/15/stm-clj-vs-haskell/