0

yogthos.net · 5d · discuss

One aspect of Clojure that I've always liked is that it is, first and foremost, a pragmatic language. It will steer you towards using functional style by default, but it also offers imperative escape hatches for performance. For example, transients are used for cases when you need to build up a big vector in a tight loop. We can mutate a transient freely, then hand back an immutable value at the end by calling persistent!. What makes transients safe is that the mutation is explicitly scoped since any further attempt to mutate the data after persistent! was called throws. So,...