DIP66 - Multiple alias this
Steven Schveighoffer
schveiguy at gmail.com
Wed Sep 30 04:48:56 UTC 2020
On 9/30/20 12:12 AM, H. S. Teoh wrote:
> On Wed, Sep 30, 2020 at 02:34:27AM +0000, Mike via Digitalmars-d wrote:
>> On Wednesday, 30 September 2020 at 02:08:17 UTC, Andrei Alexandrescu wrote:
> [...]
>>> I'd love it if interfaces could implement methods. (All MI related
>>> issues are related to state, not implementation of methods.)
>>
>> FWIW, C# 8 recently added such a feature. They call it "Default
>> Interface Members":
>> https://devblogs.microsoft.com/dotnet/default-implementations-in-interfaces/
>> However, the didn't finish the implementation and deferred this very
>> important component: https://github.com/dotnet/csharplang/issues/2337
>> I've used this feature quite a bit, but it's only mildly useful until
>> #2337 is addressed.
>
> Don't we already have this in D?
>
> interface I {
> void method1(); // overridable method
> final void method2() {} // default method
> }
> class C : I {
> void method1() {}
> }
>
> Of course, currently method bodies in interfaces are only allowed when
> it's final. This may or may not correspond with what C# does.
It looks like default method bodies are virtual and can be overridden.
I sort of remember at least having discussions about doing something
like this, but I don't think it ever happened.
-Steve
More information about the Digitalmars-d
mailing list