Copyright © 2003-2005, Peter Seibel
17. Object Reorientation: Classes
If generic functions are the verbs of the object system, classes are the nouns. As I mentioned in the previous chapter, all values in a Common Lisp program are instances of some class. Furthermore, all classes are organized into a single hierarchy rooted at the class **T**
.
The class hierarchy consists of two major families of classes, built-in and user-defined classes. Classes that represent the data types you’ve been learning about up until now, classes such as **INTEGER**
, **STRING**
, and **LIST**
, are all built-in. They live in their own section of the class hierarchy, arranged into appropriate sub- and superclass relationships, and are manipulated by the functions I’ve been discussing for much of the book up until now. You can’t subclass these classes, but, as you saw in the previous chapter, you can define methods that specialize on them, effectively extending the behavior of those classes.1
But when you want to create new nouns—for instance, the classes used in the previous chapter for representing bank accounts—you need to define your own classes. That’s the subject of this chapter.