Posted on 2008-06-15 18:53:00-07 by zby
There is no description about what inheritance trees are compatible with C3
With some inheritance trees you get an "Inconsistent hierarchy during C3 merge of class" error - but it is nowhere described (even in the liked original Dylan paper).
Direct Responses: 8084 | 8086 | Write a response
Posted on 2008-06-15 20:04:31-07 by blblack in response to 8083
Re: There is no description about what inheritance trees are compatible with C3

The Dylan paper does describe what hierarchies will be inconsistent for C3, it just isn't as straightforward about it as perhaps the C3 pod should be. The first obvious constraint is that your hierarchy can have no inheritance loops (the inheritance graph must be acyclic). Algorithm::C3 reports this error distinctly with a message like: "Infinite loop detected in parents of 'A': [A B C A]".

The other is related to monotonicity. To quote the Dylan paper: "A monotonic linearization is one in which every property inherited by a class is inherited or defined by one of its direct superclasses; that is, an inherited property cannot skip over all of the direct superclasses. This means that the linearization of a class must be an extension without reordering of the linearizations of all of its superclasses." In other words, C3's algorithm is recursive (the C3 linearization of any given class is generated from the C3 linearization of the parent classes), and if the C3 linearizations of any two (or more) parent classes contain two (or more) common superclasses, those superclasses must appear in the same order in all superclasses. If they don't, then there is no way for C3 to comply with its monotonicity constraint with respect to all superclass linearizations.

The simplest example of a graph that fails this constraint:
C isa (E, D), its C3 linearization is CED B isa (D, E), its C3 linearization is BDE A isa (B, C), its C3 linearization is invalid (DE vs ED in parent linearizations)

Note that it is only the ordering that matters - not whether other classes are present between the ones in question. This example is fine:

C isa (D, G, F), C3 linearization is CDGF B isa (D, E, F), C3 linearization is BDEF A isa (B, C), C3 linearizations is ABCDEGF
Direct Responses: 8085 | Write a response
Posted on 2008-06-15 20:18:16-07 by blblack in response to 8084
Re: There is no description about what inheritance trees are compatible with C3

Hmm I should add that although rarer, I think you can generate an invalid hierarchy via making it impossible to simultaneously satisfy both monotonicity and local precedence order at the same time. Example:

C isa (D, E) B isa (C, D, E) IF A isa (B, C), A's C3 lin is ABCDE IF A isa (C, B), A's C3 lin is invalid

The issue in the second case is that C3 gaurantees preservation of local precedence order (in other words, the ordering of @ISA won't be violated), so C3 requires on the one hand that C come before B due to the local precedence in A's @ISA, but due to B inheriting C this would violate monotonicity. (CB at the start of A's linearization vs BC at the start of B's linearizaton).

Direct Responses: Write a response
Posted on 2008-06-16 04:57:44-07 by emily in response to 8083
Re: There is no description about what inheritance trees are compatible with C3
Hello all , I hope these messages can help you : Share : how to rip DVD and convert Video to iPod at http://www.oursdownload.com/convert-DVD-video-to-iPod-video.html Share : how to rip DVD and convert Video to iphone at http://www.oursdownload.com/dvd-to-iphone.html Share : how to rip DVD and convert Video to Zune at http://www.oursdownload.com/Zune-Video-Converter,dvd-to-Zune,dvd-to-Zune-converter,Zune-converter.html Share : how to convert dvd and video to PSP at http://www.oursdownload.com/PSP-Video-Converter,dvd-to-PSP,dvd-to-PSP-converter,PSP-converter.html Only one software to convert DVD and video to iPhone,iPod,Zune,PSP at http://www.oursdownload.com/dvd-video-converter.html Share : how to convert dvd and video to Apple TV at http://www.oursdownload.com/dvd-to-apple-tv.html
Direct Responses: Write a response
Perl Weekly newsletter
A free weekly newsletter for people who are busy to read all the blogs. click here to check it out.