Default implementations in inherited interfaces

Saurabh Das via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 25 11:48:10 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 am studying the use cases for defender methods. It would be 
good to support this in D. I don't think I have enough knowledge 
about the subject to write a DIP for it yet though.




More information about the Digitalmars-d-learn mailing list