[Next] [Previous] [Up] [Top] [Contents] [Index]

2.7 Method Lookup

2.7.6 Cyclic Inheritance

In the current version of Cecil, inheritance is required to be acyclic. However, cycles in the inheritance graph would be easy to allow. Instead of defining a partial order over objects, inheritance would define a preorder, where all objects participating in a cycle are considered to inherit from all other objects in the cycle, but not be more specific than any of them. This preorder on inheritance induces a corresponding preorder on methods. The same rules for successful method lookup still apply: a single most specific method must be found. If two methods are in a cycle in the method specificity preorder, then neither is more specific than the other. In effect, objects can participate in inheritance cycles if they define disjoint sets of methods. This design of "mutually-recursive" objects could be used to factor a single large object into multiple separate objects, each implementing a separate facet of the original object's implementation.