Exhaustiveness checking in Common Lisp, part 4: dispatch-case

Sure, it’s nice to have exhaustiveness checking when dispatching on the type of a single object. But this is Lisp. What about multiple dispatch? Lisp already has a syntax for multiple dispatch: generic functions. Could you layer exhaustiveness checking on top of generic functions? Of course. But while many Lisp types have corresponding built-in classes, …

Exhaustiveness checking in Common Lisp, part 3: etypecase-of

Programmers are not to be measured by their ingenuity and their logic but by the completeness of their case analysis. Alan Perlis Let’s start with a simplified definition for etypecase-of (assuming type= from Part I). This looks very similar to ecase-of: In fact ecase-of is, conceptually, a special case of etypecase-of. You could define ecase-of …

Exhaustiveness checking in Common Lisp, part 2: The Case of the Missing ADTs

The term exhaustiveness checking comes from functional languages, and programmers experienced with functional languages may feel confused — where are the algebraic data types? In, say, Ocaml, to get exhaustiveness checking, you first have to define an ADT: This superficially resembles the deftype form above, but what it does is very different. The Ocaml defines …

Exhaustiveness checking in Common Lisp, part 1: ecase-of

A frequently heard wish is that Common Lisp had better support for static types. I am skeptical. I like the idea, but Lispers are far from pushing the boundaries of what the type system of Common Lisp already offers. What does the type system of Common Lisp offer that Lispers don’t use? For me, the …