[Issue 2050] interfaces should allow final methods with body
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Apr 28 09:12:38 PDT 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2050
------- Comment #6 from andrei at metalanguage.com 2008-04-28 11:12 -------
(In reply to comment #5)
> d-bugmail at puremagic.com wrote:
> > http://d.puremagic.com/issues/show_bug.cgi?id=2050
> >
> >
> >
> >
> >
> > ------- Comment #2 from andrei at metalanguage.com 2008-04-28 02:21 -------
> > (In reply to comment #1)
> >> That would open the door to the dreaded diamond pattern.
> >>
> >> You'd just have the compiler generate ambiguity errors in those cases I
> >> suppose?
> >
> > The diamond pattern can't occur in schemes with single inheritance of
> > implementation.
>
> That's true, but the purpose of interfaces is to allow for multiple
> inheritance in a safe way. Say you have two interfaces, IZombie from
> Library A and IPirate from Library B. You have a class ZombiePirate that
> implements both these interfaces. Right now, IZombie has a final method
> "dance()", and IPirate has the dance() method as virtual. All is well,
> since a call to an instance's dance() method would result in
> IZombie.dance()'s implementation being called. But if IPirate suddenly
> got a dance() implementation, your code would break simply by updating
> Library B.
Such cases would be flagged as ambiguous.
--
More information about the Digitalmars-d-bugs
mailing list