A video, Large-Scale Static Analysis of C++ code at Mozilla, video, July 9th, 
2010:
http://vimeo.com/12614626


>From the video I have seen that Mozilla developers have felt the need to add 
>this new attribute in C++ (implemented in JavaScript through their hydra 
>plug-ins and used with a define NS_MUST_OVERRIDE):
http://mxr.mozilla.org/mozilla-central/source/xpcom/analysis/must-override.js

I have not felt a need for it (do you see any need for it in your programs?), 
because I have not written one million lines long C++ programs, but if 
necessary I think it's not hard to add it to D as the attribute:

@must_override

(Alternative name: @to_override). It's similar to the keyword "abstract", it 
requires overloading in derived classes, but it allows the implementation of 
the method in the original class too (that's not abstract).


class Foo {
  @must_override int foo() { return 1; }
}
class Bar1 : Foo {
  int foo() { return 2; } // OK
}
class Bar2 : Foo { // error, missing foo()
}


If the creation of custom attributes in user code is allowed, then a (scoped) 
@must_override can be defined and tried out. To implement custom attributes a 
good amount of static introspection is needed.

Bye,
bearophile

Reply via email to