Default implementations in inherited interfaces

Antonio Corbi via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Jul 24 02:01:57 PDT 2016


On Sunday, 24 July 2016 at 07:54:11 UTC, Jonathan Marler wrote:
> On Thursday, 21 July 2016 at 13:37:30 UTC, Saurabh Das wrote:
>> On Thursday, 21 July 2016 at 12:42:14 UTC, Adam D. Ruppe wrote:
>>> On Thursday, 21 July 2016 at 09:41:27 UTC, Saurabh Das wrote:
>> Java 8 has a 'default' keyword that allows interfaces to 
>> provide a default implementation and sub-classes can 
>> optionally override it if needed. The rationale behind it was 
>> extending interfaces without causing old code to faill. 
>> (called "virtual extension methods" or "defender methods"). 
>> The use case is similar to above.
>>
>> Is there a way to achieve an equivalent functionality in D?
>>
>> Thanks,
>> Saurabh
>
> What an interesting technique. I've never seen this before. 
> Maybe a DIP is in order? I think it would be low priority 
> relative to the current work being done, but this technique 
> seems like a good thing to support in the language.

I first heard about this technique (or similar) in this post by 
Jim Nelson about the Vala language: 
https://blogs.gnome.org/jnelson/2011/11/01/a-few-of-my-favorite-vala-things-interface/

Antonio


More information about the Digitalmars-d-learn mailing list