override and interface methods
Andrea Fontana
nospam at example.com
Mon Oct 29 14:39:59 UTC 2018
On Monday, 29 October 2018 at 14:29:50 UTC, FeepingCreature wrote:
> On Monday, 29 October 2018 at 13:44:03 UTC, Andrea Fontana
> wrote:
>> On Monday, 29 October 2018 at 13:14:28 UTC, FeepingCreature
>> wrote:
>>> When overriding a class method, you are required to specify
>>> `override`, indicating you are redefining existing behavior.
>>>
>>> When implementing an interface method, override *can* be used
>>> but doesn't *have to* be used. This seems quite ambiguous and
>>> confusing. Am I overriding a method here? If yes, I should be
>>> required to use it. If not, I should not be *allowed* to use
>>> it.
>>>
>>> Thoughts?
>>
>> In this case you have just one choice:
>> https://run.dlang.io/is/4zWNED
>>
>> Andrea
>
> Indeed, which suggests override should be required for
> interfaces as well.
> This also seems to be the result of an informal poll in #d.
I don't think a poll with three answers is so relevant :)
They say it should be required.
Anyway if class A : AnInterface { ... } it isn't actually
override anything, because AnInterface is just an interface.
Class A is just implementing a method.
So probably you should not use override if you're not overriding
something.
Andrea
More information about the Digitalmars-d
mailing list