The Non-Virtual Interface idiom in D

Jeremie Pelletier jeremiep at gmail.com
Sun Sep 27 09:38:47 PDT 2009


Jérôme M. Berger wrote:
> Michel Fortin wrote:
>> I fully support having a way to specify a default implementation for a 
>> function in an interface. It might get handy for a few things (like 
>> implementing the delegate pattern you see everywhere in Cocoa). But 
>> it's a bad replacement for contracts.
>>
>     Then what's the difference between an interface and an abstract 
> class? I thought that the whole point of interfaces was that you 
> couldn't have implementations of the methods so that you had no problem 
> choosing an implementation when inheriting from multiple interfaces.
> 
>         Jerome

The interface supports multiple inheritance since it doesn't add to the 
vtable of the class using it, and its code would be implemented on the 
classes implementing the interface, not overridden by subclasses.



More information about the Digitalmars-d mailing list