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: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@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: -------

Reply via email to