Clojure has four reference types (var, atom, agent, and ref) that we can use to store application state. In every case, the mechanism provides a mutable container storing an immutable value. We can create the container with an initial value and reset that value. We can also advance the state using the unified update model. In this fashion, we can change the application state in a managed way.
Clojure’s reference types implement IRef. The following table lists those types along with their create, update, and reset functions:
The pattern for all of these reference types is similar: ...