[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ambiguous inheritance question



Ivan Moore <ivan@cs.man.ac.uk> writes:
> 
>                A
>               / \
>              B   C
>               \ /
>                D
> If A defines slot m, and B defines its own version of slot m, if you send D 
> the message m, you get an ambiguous selector error (as expected).
> [Why not invoke B.m]

Self used to include rules to disambiguate multiple inheritance; the
intention was to remove spurious conflicts by automatically "doing the
right thing".

The problem was that no mechanism seemed to *always* behave as
expected.  Sometimes, the default disambiguation masked an error, and
some of these errors were hard to find since the program could
continue to execute until long after the problematic send.  

In the above case, resolving the ambiguity effectively means
prioritizing B over C.  In other words, the resultion would mean (for
sends of m only!) "D is more like a B than like a C" -- after all, A's
version of m was just fine for C, and B's implementation may be wrong
for C.  It's not clear to me why such an interpretation would always
be correct -- the fact that B overrides A does not imply that B's m is
applicable to C or D.

But of course, there's a tradeoff between simplicity/safety and
convenience - without disambiguation, the programmer has to explicitly
resolve ambiguities.  On the other hand, this task could easily be
automated in the programming environment (the programmer could add
a forwarding method to D by simply pointing to B or C).  The fact that
such a tool doesn't exist for Self may indicate that the everyday
burden of explicit disambiguation is not very high.

-urs