aliasing base methods

Frank Benoit (keinfarbton) benoit at tionex.removethispart.de
Sun Feb 25 04:51:52 PST 2007


Why do we really need this strange overloading, reimplementation rules.
It is so annoying.

If you overload a method from a base class you hide the base method. To
avoid this you need to do an alias.
alias Base.fnc fnc;

If more than one version of fnc exists, you cannot specify which one
shall be alias.

There is no advantage in this. Without this rule, you can probably
overload instead of the intended override (But we already have the
override keyword, make it required?). With this rule, you probably hide
an existing base implementation and probably change the behaviour of the
class, if the overloaded function is compatible to the base version.
(e.g. visitor pattern).

Another pain point: Why do we really need to reimplement a method if an
interface is again used?
interface I{ void fnc(); }
class B : I { void fnc(){} }
class C : B, I { } // error needs to reimplement fnc.



More information about the Digitalmars-d mailing list