### Determining the Class Precedence List

The 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

R=\bigcup_{c\in {S_C}}R_c .

[Reviewer Note by Barmar: "Consistent" needs to be defined, or maybe we should say "logically consistent"?]

The set R might or might not generate a partial ordering, depending on whether the R_c, c\in 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.