www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11616] New: Introduce virtual keyword and remove virtual-by-default

reply d-bugmail puremagic.com writes:
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



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: -------
Nov 27 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616


Manu <turkeyman gmail.com> changed:

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




 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: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616






 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: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616







 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: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616





 
 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: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616






 
 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: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616




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: -------
Feb 12 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616




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


Issue 11616 - Introduce virtual keyword

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 25 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616


bearophile_hugs eml.cc changed:

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



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: -------
Feb 26 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616





 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: -------
Feb 26 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616






 An oversight, it should give you an error the same as ` safe  system void
 fun();`  does.  Please file a bug for it.
Yet it seems C++11 allows it: http://en.wikipedia.org/wiki/C%2B%2B0x#Explicit_overrides_and_final http://stackoverflow.com/questions/6788338/final-virtual-functions-in-c0x http://stackoverflow.com/questions/11704406/whats-the-point-of-a-final-virtual-function -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11616






 
 An oversight, it should give you an error the same as ` safe  system void
 fun();`  does.  Please file a bug for it.
Yet it seems C++11 allows it: http://en.wikipedia.org/wiki/C%2B%2B0x#Explicit_overrides_and_final http://stackoverflow.com/questions/6788338/final-virtual-functions-in-c0x http://stackoverflow.com/questions/11704406/whats-the-point-of-a-final-virtual-function
Interesting... Still, because we have attribute scopes/labels that would be harmful in D. eg virtual: final: void fun(); Here fun should be final, not both virtual and final. This should behave the same way as "virtual final". -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Feb 26 2014