Jump to page: 1 2
Thread overview
[Issue 11616] New: Introduce virtual keyword and remove virtual-by-default
Nov 27, 2013
yebblies
Nov 27, 2013
Manu
Nov 27, 2013
yebblies
Nov 27, 2013
Manu
Nov 27, 2013
yebblies
Nov 27, 2013
Manu
Feb 12, 2014
Andrej Mitrovic
Feb 26, 2014
yebblies
Feb 26, 2014
yebblies
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616

           Summary: Introduce virtual keyword and remove
                    virtual-by-default
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: preapproved
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: yebblies@gmail.com
        ReportedBy: yebblies@gmail.com


--- Comment #0 from yebblies <yebblies@gmail.com> 2013-11-27 23:27:49 EST ---
Thread with discussion and Walter-approval:

http://forum.dlang.org/thread/yzsqwejxqlnzryhrkfuq@forum.dlang.org?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)

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616


Manu <turkeyman@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |turkeyman@gmail.com


--- Comment #1 from Manu <turkeyman@gmail.com> 2013-11-27 05:18:15 PST ---
(In reply to comment #0)
> Thread with discussion and Walter-approval:
> 
> http://forum.dlang.org/thread/yzsqwejxqlnzryhrkfuq@forum.dlang.org?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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #2 from yebblies <yebblies@gmail.com> 2013-11-28 00:46:08 EST ---
(In reply to comment #1)
> (In reply to comment #0)
> > Thread with discussion and Walter-approval:
> > 
> > http://forum.dlang.org/thread/yzsqwejxqlnzryhrkfuq@forum.dlang.org?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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #3 from Manu <turkeyman@gmail.com> 2013-11-27 06:58:10 PST ---
(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/yzsqwejxqlnzryhrkfuq@forum.dlang.org?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?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #4 from yebblies <yebblies@gmail.com> 2013-11-28 02:07:18 EST ---
(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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
November 27, 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #5 from Manu <turkeyman@gmail.com> 2013-11-27 07:29:23 PST ---
(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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 12, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #6 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2014-02-12 12:58:07 PST ---
*** Issue 7726 has been marked as a duplicate of this issue. ***

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 25, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #7 from github-bugzilla@puremagic.com 2014-02-25 15:38:44 PST ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/b900262a9cbde7247a5eb0abc9de218500f7e229 Issue 11616 - Introduce virtual keyword

Introduce the virtual keyword

https://github.com/D-Programming-Language/dmd/commit/28acc4a364f751225b544b12c082dab037783d12 Merge pull request #2895 from yebblies/issue11616

Issue 11616 - Introduce virtual keyword

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11616


bearophile_hugs@eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs@eml.cc


--- Comment #8 from bearophile_hugs@eml.cc 2014-02-26 04:26:41 PST ---
A possibly silly question, is this code OK (currently it compiles)?


class Foo {
    virtual final void bar() {}
}
void main() {}

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
February 26, 2014
https://d.puremagic.com/issues/show_bug.cgi?id=11616



--- Comment #9 from yebblies <yebblies@gmail.com> 2014-02-26 23:33:07 EST ---
(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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2