
Allegro CL 
ANSI Common Lisp 4 Types and Classes 4.3 Classes
4.3.5 Determining the Class Precedence ListThe defclass form for a class provides a total ordering on that class and its direct superclasses. This ordering is called the local precedence order. It is an ordered list of the class and its direct superclasses. The class precedence list for a class C is a total ordering on C and its superclasses that is consistent with the local precedence orders for each of C and its superclasses.A class precedes its direct superclasses, and a direct superclass precedes all other direct superclasses specified to its right in the superclasses list of the defclass form. For every class C, define R_{C}={(C,C_{1}),(C_{1},C_{2}), ... ,(C_{n}1,C_{n})} where C_{1}, ... ,C_{n} are the direct superclasses of C in the order in which they are mentioned in the defclass form. These ordered pairs generate the total ordering on the class C and its direct superclasses. Let S_{C} be the set of C and its superclasses. Let R be
The set R might or might not generate a partial ordering, depending on whether the R_{c}, c S_{C}, are consistent; it is assumed that they are consistent and that R generates a partial ordering. When the R_{c} are not consistent, it is said that R is inconsistent. To compute the class precedence list for C, topologically sort the elements of S_{C} with respect to the partial ordering generated by R. When the topological sort must select a class from a set of two or more classes, none of which are preceded by other classes with respect to R, the class selected is chosen deterministically, as described below. If R is inconsistent, an error is signaled.
