|
|
|
|
|
by eduction
427 days ago
|
|
That’s incorrect. Only refs+dosync use stm. https://clojure.org/reference/refs Not atoms. From Hickey’s History of Clojure paper: “ Taking on the design and implementation of an STM was a lot to add atop designing a programming language. In practice, the STM is rarely needed or used. It is quite
common for Clojure programs to use only atoms for state, and even then only one or a handful of atoms in an entire program. But when a program needs coordinated state it really needs it, and without the STM I did not think Clojure would be fully practical.” https://dl.acm.org/doi/pdf/10.1145/3386321 Atoms do an atomic compare and swap. It’s not the same thing. |
|
That said, I have never used a ref, nor seen one in use outside of a demo blogpost.