Appendix B: The Common Lisp Object System
But while an ordinary function has a single body of code that is always executed, a generic function has a set of bodies of code, called methods. When a generic function is called on an instance, the function looks at the class or classes of the instance. In the simplest case, the generic function has a method for the instance's class. (For example, the generic function #'set-part-color has a method for table-dialog-item. Calling #'set-part-color on an instance of table-dialog-item calls that method. Calling #'set-part-color on an instance of radio-button-dialog-item calls a different method.)
In cases where the instance's class has a complex parentage, methods may be combined. What the function does--which bodies of code are called and how they are combined--is calculated from the class precedence list, the total ordering of the set of classes from which a class inherits. It also depends on the method combination type.
You can define a generic function by using the macro defgeneric. More often, however, you use defmethod, which defines a method on a generic function for a particular class. If the generic function does not already exist, defmethod creates one.
Generated with Harlequin WebMaker