Hi !
I'm posting this on comp.lang.lisp as well because my usenet provider
doesn't have any news in comp.lang.dylan, so I suspect something is
rotten in the state of Denmark...
Consider this:
define class <mymix> ()
end class <mymix>;
define class <mysuper> (<mymix>)
end class <mysuper>;
define class <myclass> (<mymix>, <mysuper>)
end class <myclass>;
define method foobar (obj :: <mymix>)
format-out("MyMix method.\n");
end method foobar;
define method foobar (obj :: <mysuper>)
format-out("MySuper method.\n");
end method foobar;
define function main(name, arguments)
let myobject = make (<myclass>);
foobar (myobject);
exit-application(0);
end function main;
If it were common lisp code, this wouldn't compile because the class
precedence order can't be computed. Not surprising. Now, with opendylan
(1.0b4), this triggers a "serious warning" but compiles fine.
The foobar method actually called is the mymix one, which is puzzling to
me. But then, if I remove the method specialized on mymix, I get both a
serious warning and a run-time error stating that myobject is not of
class mysuper. This suggests that the compiler effectively removed
mysuper from the (multiple-)inheritance graph of myclass. ?!?!
Can somebody enlighten me ?
Thanks.
--
5th European Lisp Workshop at ECOOP 2008, July 7: http://elw.bknr.net/2008/
Didier Verna, ······@lrde.epita.fr, http://www.lrde.epita.fr/~didier
EPITA / LRDE, 14-16 rue Voltaire Tel.+33 (0)1 44 08 01 85
94276 Le Kremlin-Bic�tre, France Fax.+33 (0)1 53 14 59 22 ······@xemacs.org
On Tue, 17 Jun 2008 15:23:33 +0200, Didier Verna wrote:
> Hi !
>
> I'm posting this on comp.lang.lisp as well because my usenet provider
> doesn't have any news in comp.lang.dylan, so I suspect something is
> rotten in the state of Denmark...
>
> Consider this:
>
> define class <mymix> ()
> end class <mymix>;
>
> define class <mysuper> (<mymix>)
> end class <mysuper>;
>
> define class <myclass> (<mymix>, <mysuper>)
> end class <myclass>;
>
> define method foobar (obj :: <mymix>)
> format-out("MyMix method.\n");
> end method foobar;
>
> define method foobar (obj :: <mysuper>)
> format-out("MySuper method.\n");
> end method foobar;
>
> define function main(name, arguments)
> let myobject = make (<myclass>);
> foobar (myobject);
> exit-application(0);
> end function main;
>
>
> If it were common lisp code, this wouldn't compile because the class
> precedence order can't be computed. Not surprising. Now, with opendylan
> (1.0b4), this triggers a "serious warning" but compiles fine.
>
> The foobar method actually called is the mymix one, which is puzzling to
> me. But then, if I remove the method specialized on mymix, I get both a
> serious warning and a run-time error stating that myobject is not of
> class mysuper. This suggests that the compiler effectively removed
> mysuper from the (multiple-)inheritance graph of myclass. ?!?!
>
> Can somebody enlighten me ?
Maybe: http://en.wikipedia.org/wiki/C3_linearization
or: http://192.220.96.201/dylan/linearization-oopsla96.html
This is referenced from:
http://www.cliki.net/C3%20superclass%20linearization%20MRO
HTH Ralf Mattes
> Thanks.
>