Hi Tucker,
I read your wiki page about mixins, http://wiki.openlaszlo.org/Mixins. I
wrote an application to verify that inheritance works as described (it
does). I defined a draw() member in a base class, two mixins, and a
subclass (see Example 1 below). When you run this it displays:
baseclass.draw init
drawmixin2.draw init
drawmixin1.draw init
myclass.draw init
My worry isn't that multiple mixin draw() methods are called, but rather
the opposite case. If this mixin is used in another example, you can
wind up calling a non-existent super class. See Example 2. This is the
same as Example 1 except that there is no base class.
Is there a way the application can detect (at runtime) that there is no
super class?
Thanks!
Phil
EXAMPLE 1:
<canvas debug="true">
<class name="baseclass">
<method name="draw" args="str">
Debug.write("baseclass.draw", str);
</method>
</class>
<mixin name="drawmixin1">
<method name="draw" args="str">
super.draw(str);
Debug.write("drawmixin1.draw", str);
</method>
</mixin>
<mixin name="drawmixin2">
<method name="draw" args="str">
super.draw(str);
Debug.write("drawmixin2.draw", str);
</method>
</mixin>
<class name="myclass" extends="baseclass"
with="drawmixin1,drawmixin2">
<method name="draw" args="str">
super.draw(str);
Debug.write("myclass.draw", str);
</method>
</class>
<myclass name="c1"/>
<handler name="oninit">
c1.draw ("init");
</handler>
</canvas>
EXAMPLE 2:
<canvas debug="true">
<mixin name="drawmixin1">
<method name="draw" args="str">
super.draw(str);
Debug.write("drawmixin1.draw", str);
</method>
</mixin>
<mixin name="drawmixin2">
<method name="draw" args="str">
super.draw(str);
Debug.write("drawmixin2.draw", str);
</method>
</mixin>
<class name="myclass" with="drawmixin1,drawmixin2">
<method name="draw" args="str">
super.draw(str);
Debug.write("myclass.draw", str);
</method>
</class>
<myclass name="c1"/>
<handler name="oninit">
c1.draw ("init");
</handler>
</canvas>