The Clojure Model

Clojure provides a different model. To explain it, let’s revisit the terms value, state, and identity and give them definitions that might be a bit different from the ones you’re used to.

In Clojure’s world, a value is an immutable piece of data, or a composite of immutable pieces of data. This differs from what we might consider a value in most object-oriented languages, where we’d consider both immutable data, such as integers and strings, and mutable data, such as most objects, to be values.

Next up is the notion of an identity. An identity is an entity that’s associated with a series of values over time. An identity is not a place, like a mutable memory cell, or the mutable objects we saw earlier. Neither is an identity ...

Get Functional Programming: A PragPub Anthology now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.