FSet is a functional, set-theoretic collections library for Common Lisp. Functional means that all update operations return a new collection rather than modifying an existing one in place. Don’t be daunted by the term “set-theoretic”! It just means that the collections have clean semantics, and may be nested arbitrarily with no additional programmer effort — for instance, sets may contain sets, maps may be keyed by sets, etc.
FSet is designed to be an excellent default choice for collections in Common Lisp programs: you can use them in practically all cases where you need a collection. It has a wide API, with sets, maps, bags (multisets), seqs (sequences), binary relations, tuples, and more; and lots of useful operations on these types. FSet is very much intended to be useful for general programming; I believe that functional collections are superior from a software engineering perspective, leading to more elegant and reliable code. (The same thesis drove Rich Hickey’s design of Clojure.)
Along with supporting and encouraging the use of functional collections, FSet also seeks to bring Common Lisp up to date, adding to it data structures invented since the language was designed. These data structures greatly expand the space of algorithms that can be written in an elegant functional style and still run efficiently.
This book has two intended audiences. The larger one is Common Lisp programmers, or people who at least have been learning the language, who want to explore the benefits of modern functional collections.
There’s a second audience, however, I also hope to reach, consisting not of people who expect to use Common Lisp or FSet, but rather designers of other languages and/or libraries for those languages. I refer such readers to the chapters Conceptual Background and Recommendations for Language Designers; the other chapters will still be worth reading, I think, but of less importance.
For those who may want to actually use FSet, though, this book does assume some basic proficiency in Common Lisp; I don’t recommend it as a first text for those learning the language. You will need to know, at the very least:
For a fuller understanding, these topics will also be helpful:
defclass or deftype
defmethod