implement vs override
Peter C
peterc at gmail.com
Sun Nov 2 23:13:08 UTC 2025
On Sunday, 2 November 2025 at 11:33:56 UTC, Dejan Lekic wrote:
> On Sunday, 2 November 2025 at 00:00:35 UTC, Peter C wrote:
>> Just because you know what it means, doesn't mean I know what
>> it means.
>
> I am trying very hard to understand you here - you, as
> developer who wrote the code, deliberately made a decision to
> inherit from Base class. This means you _do know_ what it means
> (what that class does).
There is no indication to me that Base intended to implement the
semantic requirements of the interface. Do you understand that?
And yet, Base.someMethod() is considered an implementation of the
interface. I understand that the compiler undertands this
(because it has the same signature), but really, the compiler is
just taking the easiest possible path here.
It's still not clear to *me* (regardless of the rules here) that
by simply inherting a method from Base that has the same
signature, that it automatically satisfies the semantic
requirements of the interface.
The person maintaining this code will likely ask the same
question I did - does Derived implement the semantic requirement
of the interface, or not?
A C# like explicit interface declaration in D, would have solved
this question straight away. The intent would have been clear,
and I would have understood immediately that Derived has indeed
implemented the semantic requirement of the interface.
D's starting to remind me of that scene in Ghostbusters, where
Peter drives up with (what will become) the ghostbusters vehicle.
i.e. look promising, but will need a lot of work.
More information about the Digitalmars-d
mailing list