DIP66 - Multiple alias this
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Sep 30 04:12:28 UTC 2020
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.
T
--
My program has no bugs! Only undocumented features...
More information about the Digitalmars-d
mailing list