If I understood correctly, you interpret “ordering rules imposed by inheritance relationships”, in Guido’s quote, exclusively as those appearing in the classes’ definitions, the local precedence order (LPO). This, as opposed to LPO plus the order from previously computed MROs for those classes, which I guess could be another interpretation.
Questions:
- To do topological sort to determine the MRO of a new class, one would need to visit the whole hierarchy (following
__bases__
), rather than the MRO of the parents, right? - Suppose a class’ MRO has been computed. Assume that the corresponding topological sort chose a precedence A\prec B that is not imposed by the LPO. For example, your
A0_B
that admits the topological sortsA0_B, A, B
orA0_B, B, A
. Assume that whenA0_B
was defined, the first topological sort was chosen. Later a new class is defined that does impose B\prec A. For exampleclass C(B,A): pass
. Would the MRO of the first class (A0_B
) be updated toA0_B, B, A
or left asA0_B, A, B
?
I think that if the answer to (2) is leave already computed MRO as they are, then monotonicity need not be satisfied. If the answer is to update all MROs, then they could be constantly changing as more classes get defined.
There is a property, that in the paper A monotonic superclass linearization for Dylan is called acceptable, that is that “only the shape of a class’s inheritance graph may be used in determining the linearization”. I understood this as A0_B
’s linearization shouldn’t depend on C
’s. I think that if all MRO’s get updated, then this property cannot be satisfied. Right?