[Issue 3836] New: obligatory override attribute

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 18 13:15:10 PST 2010


http://d.puremagic.com/issues/show_bug.cgi?id=3836

           Summary: obligatory override attribute
           Product: D
           Version: 2.040
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2010-02-18 13:15:09 PST ---
override attribute is better to become obligatory (even when no -w is used) as
in C#, to avoid mistakes like this:

import std.stdio;

class Dog {
    public static void bark() {
        writeln("woof ");
    }
}

class Basenji : Dog {
    public static void bark() {}
}

void main() {
    Dog woofer = new Dog();
    Dog nipper = new Basenji();
    woofer.bark();
    nipper.bark();
}

If the programmer knows that override is present if and only if a method
override another one, then this code can't be ambiguous.

(I think in C++ the obligatory override attribute is less necessary because
methods are not virtual by default, so only if you add an explicit "virtual" a
method can be overriden).

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


More information about the Digitalmars-d-bugs mailing list