override and interface methods

Steven Schveighoffer schveiguy at gmail.com
Mon Oct 29 17:13:22 UTC 2018


On 10/29/18 11:41 AM, FeepingCreature wrote:
> On Monday, 29 October 2018 at 15:30:27 UTC, Steven Schveighoffer wrote:
>> For sure, we can't add a requirement for override on an interface, as 
>> you aren't exactly overriding an existing implementation. Too much 
>> code is out there that does not specify override for interfaces.
>>
> 
> Isn't that what the deprecate cycle exists for? I mean, it seems like a 
> symmetrical issue to what you had with regular class override. And the 
> argument that "it's not override on an interface" really seems straight 
> up wrong to me, since you *can* write override - the compiler *already* 
> agrees that implementing an interface method falls under the override 
> umbrella.

That is something I'm not 100% sure about (the history anyway). I seem 
to remember that at one point override was an error for interfaces, but 
maybe that was just what some people wanted to implement.

In other words, I think it *was* that way at one point, but the rules 
were relaxed, but I may be wrong.

In any case, I'd prefer a relaxed rule here as there is no hijacking 
involved for interfaces (which is what the override requirement solves), 
it will just break valid code for a trivial reason. The case is NOT 
symmetrical.

-Steve


More information about the Digitalmars-d mailing list