www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Alias this conflict

In the D Conf presentation , we get the new syntax of

struct M{
    int a;
    int b;
}

struct S{
    M m;
    alias m this;
}

It's a great feature. While it could conflict with the possible alias of  
super.ctor ?

consider:

class B{
     this()
     {
         writefln("base ctor");
     }
     void foo()
     {}
}

class A:B{
     this (int i)
     {
         writefln("inherited class ctor");
     }
     // oops! super.ctor get hidden , write such a ctor is somewhat trivial
     alias B.foo foo;    // we bring the foo to this scope
     void foo(int i){}
}

One way of bringing the super class ctor to the current scope should be  
some thing like the way of bringing the super class method to the current  
scope( we use alias B.foo foo;)

So it's consistent to write alias super.this this; but now it gets a  
different meaning.




-- 
使用 Opera 革命性的电子邮件客户程序: http://www.opera.com/mail/
Aug 26 2007