On 2009-11-20, at 12:28, Rami Ojares / AMG Oy wrote: > So one could say that the mixins are inserted in to the inheritance chain. I > think I got it now. > > > You can't say `super.super`, you can't get around the built-in > > inheritance chain. This is part of the power (and danger) of mixins. > > > With a single-inheritance language, it should not be too surprising or > > > confusing. It gets more complicated if your language is a > > multiple-inheritance language (more than you probably every want to > > know about the issue here: http://bit.ly/6iixlA). > > Thanks for the link. Unfortunately it requires payment however the abstract > has this to say about the dangers of super.super
Amusingly, Google can find an unprotected copy on one of the co-author's web servers: http://bit.ly/5NT2bf > "Recent work has defined several desirable characteristics for > linearizations, the most important being monotonicity, which prohibits > inherited properties from skipping over direct superclasses" > ... > "a monotonic linearization enables some compile-time method selection that > would otherwise be impossible in the absence of a closed-world assumption" > > So if you don't mind I would like to know what would be the danger of > skipping on superclass? > > And could the compiler not know exactly the same way which method to call > even if super.super was used? Since it must know the complete inheritance > hierarchy then when encountering super.super it would know to go 2 levels up > instead of just one. > > And you can omit all considerations of multiple inheritance since laszlo (and > javascript) do not have it. (As a matter of fact isn't the keyword super > always ambiguous in case of multiple inheritance?) [ASIDE: Edition 4 had some provisions for generic functions, which soon lead on to multiple-inheritance. You may see it yet in Javascript. Much of the rationale behind single-inheritance is not because it is "the right thing" for the programmer, it is because it was the easy thing for the compiler implementor.] There is a really good overview of the current research into inheritance in object-oriented languages available here: http://bit.ly/4szjKD That particular paper argues that mixins and multiple-inheritance are all too powerful and too confusing. I disagree with some of the paper, but there is a lot of good background there. I think the basic idea behind the restrictions that are imposed on mixins and inheritance are sound: that there should not be any surprises. It's hard to give simple examples, but the collective (40+ year) experience in the O-O community is that whenever you think you need to say super.super, or directly call an inherited method in a superclass, you will end up regretting it if you do, inevitably at a later time or in some descendant class when the little "work around" will have been long forgotten.
