O'Reilly logo

Clojure Applied by Alex Miller, Ben Vandgrift

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Modeling a Change

Recall that Clojure’s focus is on immutable values. With immutable data, an “update” produces a new instance of an entity (or collection of entities), rather than updating the entity or entities in place. In most cases, this will serve your purposes admirably. Occasionally, you’ll need to model the changes in the application’s world, to track changes in data. Specifically, you want to hold onto a reference to a set of data that changes.

In a multithreaded scenario, updating data in place introduces a lot of complex questions. Who can change the data? How do other threads get notified of the change? Which process wins when multiple simultaneous updates are happening? Clojure provides elegant answers to all of these questions ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required