Could new keyword help function hijacking and prevented aliasing all over the place??

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri May 27 07:10:25 PDT 2011


On 5/27/11 1:34 AM, Matthew Ong wrote:
> Hi All,
>
> Currently within D, to make use of a parent class method you have to do:
> class Parent{
> void methodA(int x){...}
> }
>
> class Child : Parent{
> // I understand that it has to do with preventing accidental hijacking
> alias Parent.methodA methodA;
> void methodA(long x){...}
> }
>
> void main(string[]){
> Child obj=new Child();
> obj.methodA(1); // expecting to call Child.methodA but calling
> Parent.methodA;
> }
>
> and also from this URL.
> http://www.digitalmars.com/d/2.0/function.html
> If, through implicit conversions to the base class, those other
> functions do get called, an std.HiddenFuncError exception is raised.

I can't believe this has fallen off the radar.

There should be no std.HiddenFuncError. Such errors must ALL be detected 
during compilation.


Andrei


More information about the Digitalmars-d mailing list