2 ms·
The text below is directly lifted from the Clojure site at: http://clojure.org/state http://clojure.org/state The article describes it more clearly and succinct
by nkh 16y ago
The text below is directly lifted from the Clojure site at: http://clojure.org/state http://clojure.org/state The article describes it more clearly and succinctly then I could.
There is another way, and that is to separate identity and state (once again, indirection saves the day in programming). We need to move away from a notion of state as "the content of this memory block" to one of "the value currently associated with this identity". Thus an identity can be in different states at different times, but the state itself doesn't change. That is, an identity is not a state, an identity has a state. Exactly one state at any point in time. And that state is a true value, i.e. it never changes. If an identity appears to change, it is because it becomes associated with different state values over time. This is the Clojure model.
- jules 16y agoSo is he saying that you should not nest refs? i.e. you should not create a vector of refs and assign the vector to a ref. Because now the state itself can change.