10.4.1 Clojure

Rich Hickey’s creation of Clojure has been massively impactful in popularizing functional collections. Looking over its API from an FSet point of view, it is hard to find much to criticize. Our choices of operation names are somewhat different — for with and less, Clojure uses conj and disj on sets and assoc and dissoc on maps. But in terms of functionality, there’s a lot of overlap.

Clojure tries harder than Common Lisp does to enforce a mostly-functional style; it doesn’t permit assigning new values to existing local variables. But it’s not completely pure: there are references that can be updated within transactions. For that purpose there is alter, which is a general quasi-mutating operator.

One significant difference is that Clojure uses abstract equality while FSet, following Common Lisp, uses concrete equality.

Clojure does not have as rich a collection of map-combining operators as FSet. Clojure’s merge is like map-union, except that there is no val-fn parameter to alter the behavior that pairs from the right operand shadow those from the left. So it’s less general than map-union; and there’s nothing equivalent to map-intersection or map-difference.

On the other hand, Clojure has general relations, which are on my wishlist for FSet, but not yet written.