Thread with discussion and Walter-approval:
http://forum.dlang.org/thread/[email protected]?page=28#post-koqkhc:244nn:241:40digitalmars.com
1. Add warning for not marking a virtual method with 'virtual'
2. Deprecate not marking a virtual method with 'virtual'
3. Make it an error to not mark virtual methods with 'virtual'
At this point, all methods are marked with either 'virtual', 'final', 'abstract', or 'override' or are implicitly final. (eg template methods, constructors)
4. Do not require 'final' to mark a function as final. (optional)
Comment #1 by turkeyman — 2013-11-27T05:18:15Z
(In reply to comment #0)
> Thread with discussion and Walter-approval:
>
> http://forum.dlang.org/thread/[email protected]?page=28#post-koqkhc:244nn:241:40digitalmars.com
>
> 1. Add warning for not marking a virtual method with 'virtual'
> 2. Deprecate not marking a virtual method with 'virtual'
> 3. Make it an error to not mark virtual methods with 'virtual'
>
> At this point, all methods are marked with either 'virtual', 'final',
> 'abstract', or 'override' or are implicitly final. (eg template methods,
> constructors)
>
> 4. Do not require 'final' to mark a function as final. (optional)
Since I already started writing this, I may as well paste it here:
http://wiki.dlang.org/DIP51
It can be updated if details emerge.
Comment #2 by yebblies — 2013-11-27T05:46:08Z
(In reply to comment #1)
> (In reply to comment #0)
> > Thread with discussion and Walter-approval:
> >
> > http://forum.dlang.org/thread/[email protected]?page=28#post-koqkhc:244nn:241:40digitalmars.com
> >
> > 1. Add warning for not marking a virtual method with 'virtual'
> > 2. Deprecate not marking a virtual method with 'virtual'
> > 3. Make it an error to not mark virtual methods with 'virtual'
> >
> > At this point, all methods are marked with either 'virtual', 'final',
> > 'abstract', or 'override' or are implicitly final. (eg template methods,
> > constructors)
> >
> > 4. Do not require 'final' to mark a function as final. (optional)
>
> Since I already started writing this, I may as well paste it here:
> http://wiki.dlang.org/DIP51
> It can be updated if details emerge.
I updated it. The warning goes on the introducing method, not on the overriding one. This forces all methods to be correctly annotated, even if there are no derived classes.
Comment #3 by turkeyman — 2013-11-27T06:58:10Z
(In reply to comment #2)
> (In reply to comment #1)
> > (In reply to comment #0)
> > > Thread with discussion and Walter-approval:
> > >
> > > http://forum.dlang.org/thread/[email protected]?page=28#post-koqkhc:244nn:241:40digitalmars.com
> > >
> > > 1. Add warning for not marking a virtual method with 'virtual'
> > > 2. Deprecate not marking a virtual method with 'virtual'
> > > 3. Make it an error to not mark virtual methods with 'virtual'
> > >
> > > At this point, all methods are marked with either 'virtual', 'final',
> > > 'abstract', or 'override' or are implicitly final. (eg template methods,
> > > constructors)
> > >
> > > 4. Do not require 'final' to mark a function as final. (optional)
> >
> > Since I already started writing this, I may as well paste it here:
> > http://wiki.dlang.org/DIP51
> > It can be updated if details emerge.
>
> I updated it. The warning goes on the introducing method, not on the
> overriding one. This forces all methods to be correctly annotated, even if
> there are no derived classes.
You mean to disallow an implicit state? So it's not final-by-default, rather, it MUST be explicitly specified?
Comment #4 by yebblies — 2013-11-27T07:07:18Z
(In reply to comment #3)
>
> You mean to disallow an implicit state? So it's not final-by-default, rather,
> it MUST be explicitly specified?
final-by-default comes last. The plan is to force the user to annotate everything, then relax the rules again. This way no functions move from virtual->non-virtual without user intervention.
Comment #5 by turkeyman — 2013-11-27T07:29:23Z
(In reply to comment #4)
> (In reply to comment #3)
> >
> > You mean to disallow an implicit state? So it's not final-by-default, rather,
> > it MUST be explicitly specified?
>
> final-by-default comes last. The plan is to force the user to annotate
> everything, then relax the rules again. This way no functions move from
> virtual->non-virtual without user intervention.
Hmmm, okay. I guess that's fair enough. It makes it explicit for a while then there's no ambiguity of intent.
Comment #6 by andrej.mitrovich — 2014-02-12T12:58:07Z
*** Issue 7726 has been marked as a duplicate of this issue. ***
Comment #7 by github-bugzilla — 2014-02-25T15:38:44Z
Comment #8 by bearophile_hugs — 2014-02-26T04:26:41Z
A possibly silly question, is this code OK (currently it compiles)?
class Foo {
virtual final void bar() {}
}
void main() {}
Comment #9 by yebblies — 2014-02-26T04:33:07Z
(In reply to comment #8)
> A possibly silly question, is this code OK (currently it compiles)?
>
>
> class Foo {
> virtual final void bar() {}
> }
> void main() {}
An oversight, it should give you an error the same as `@safe @system void fun();` does. Please file a bug for it.
Comment #10 by bearophile_hugs — 2014-02-26T04:54:07Z