When does final mean "maybe, kinda, sorta" ?
kris
foo at bar.com
Tue Jan 23 09:20:18 PST 2007
Steve Horne wrote:
> On Tue, 23 Jan 2007 00:26:10 -0800, kris <foo at bar.com> wrote:
>
>
>>Steve Horne wrote:
>>[snip]
>>
>>
>>>And adding a new private member to a base class should not
>>>break any derived classes that might happen to already use the same
>>>signature for a (private or public) method, especially since you may
>>>have no control or even knowledge of those derived classes.
>>
>>Given that, I'd imagine you'd be a proponent of making 'override' a
>>required keyword? After all, not requiring it will likely lead to the
>>same type of problem when a base-class method is removed.
>>
>>Yet, judging by past record, override is unlikely to ever be required.
>
>
> Override should only be specified when the intent is to override, IMO.
>
> If adding a new public/protected method to a base class results in its
> accidentally being overridden by a pre-existing conflicting
> derived-class method, clearly that's bad. So...
>
> 1. Specifying override on a method that doesn't override any base
> class method should be an error.
> 2. Failing to specify override on a method that does override a base
> class public/protected method should be an error.
>
> I thought that was what D does anyway, and for that matter that it was
> the whole point of the override keyword
[snip]
(1) does generate an error, but (2) has never generated one, and
requests to make it do so have met with silence from W for years :)
Everything else you say I agree with, and thanks for taking the time to
respond in such detail.
- Kris
More information about the Digitalmars-d
mailing list