www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7259] New: Explicit annotation for method hiding

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7259

           Summary: Explicit annotation for method hiding
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



I'd like to see D care more about this, method hiding:


class Foo {
    string name = "c1";
    static void foo() {}
}
class Bar : Foo {
    string name = "c2";
    static void foo() {} // silent method hiding
}
void main() {}



(as with 'override', it first becomes a warning):


class Foo {
    string name = "c1";
    static void foo() {}
}
class Bar : Foo {
    string name = "c2";
    static new void foo() {} // method hiding is now visible
}
void main() {}


The point here is to make the purpose and meaning of the code more explicit.

---------------------

See also an answer by Jesse Phillips:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=154448

 Override usage is going to be (hopefully soon) compulsory in D
 (currently you need -w to see an error). So that code without
 both static and override is going to be refused :-)
I guess the question I was getting at, currently there is no way with 'new.' Is that intended once 'override' is required? and if not why have 'new' usable for static methods?
-- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Jan 09 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7259


Alex Rønne Petersen <xtzgzorex gmail.com> changed:

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



12:52:24 PST ---
I completely agree. If we have mandatory override, we should have this as well.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 09 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7259




See also:

http://msdn.microsoft.com/en-us/library/51y09td4%28v=vs.71%29.aspx

http://blogs.msdn.com/b/csharpfaq/archive/2004/03/12/what-s-the-difference-between-code-override-code-and-code-new-code.aspx

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 14 2012