On 2009-11-20, at 11:06, Rami Ojares / AMG Oy wrote:
> > It works like this:
> > <class name="a" extends="b" with="c, d, e">
> > To find a property (attribute, method, etc.) in an instance, look in
> > this order: <instance>, a, c, d, e, b, <b's inheritance list>
>
> So let's say I am now at class:a level.
> Can I call super.foo() to call c.foo()
> And further can I call super.super.foo() to call d's foo method and so forth?
> (I know this is not possible in java)
When you call super.foo in any class or mixin, it looks up the (automatically
computed) "inheritance chain".
<canvas>
<class name="etc">
<method name="foo">return "<b's inheritance list>"</method>
</class>
<class name="b" extends="etc">
<method name="foo">return "b -> " + super.foo()</method>
</class>
<class name="c">
<method name="foo">return "c -> " + super.foo()</method>
</class>
<class name="d">
<method name="foo">return "d -> " + super.foo()</method>
</class>
<class name="e">
<method name="foo">return "e -> " + super.foo()</method>
</class>
<class name="a" extends="b" with="c, d, e">
<method name="foo">return "a -> " + super.foo()</method>
</class>
<a oninit="foo()">
<method name="foo">Debug.info("<instance> -> " + super.foo())</method>
</a>
</canvas>
Will display:
INFO @mixample.lzx#21: <instance> -> a -> c -> d -> e -> b -> <b's inheritance
list>
Try playing with that example. Shuffle the mixin's around, remove a foo method
or two. You'll get the idea.
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).