digitalmars.D - typedef-ed ctor [feature enhancement]
- typedef d.com (24/24) May 09 2005 Suppose a class has ctor defined, then a typedef-ed class cannot use tha...
- Andrew Fedoniouk (3/33) May 09 2005 For me it looks like just a bug of current implementation.
Suppose a class has ctor defined, then a typedef-ed class cannot use that ctor: ------------------------------------------------------------ class A { public this(int param) {} } typedef A B; #void foo() { ------------------------------------------------------------ by contrast, if no ctor defined in A, then it works: ------------------------------------------------------------ class A {} typedef A B; void foo() { A a = new A(); //OK B b = new B(); //OK } ------------------------------------------------------------ I think we should make the first example also work, otherwise many non-trivial typedef-ed class cannot call ctor; this will make typedef less useful (people will start to use alias everywhere). So the desired behaviour should be: B b = new A(); // wrong! expected: you cannot assign A to B B b = new B(); // should work here, because B is B!
May 09 2005
For me it looks like just a bug of current implementation. ------------------------------------------ <typedef d.com> wrote in message news:d5o9mb$17ok$1 digitaldaemon.com...Suppose a class has ctor defined, then a typedef-ed class cannot use that ctor: ------------------------------------------------------------ class A { public this(int param) {} } typedef A B; #void foo() { ------------------------------------------------------------ by contrast, if no ctor defined in A, then it works: ------------------------------------------------------------ class A {} typedef A B; void foo() { A a = new A(); //OK B b = new B(); //OK } ------------------------------------------------------------ I think we should make the first example also work, otherwise many non-trivial typedef-ed class cannot call ctor; this will make typedef less useful (people will start to use alias everywhere). So the desired behaviour should be: B b = new A(); // wrong! expected: you cannot assign A to B B b = new B(); // should work here, because B is B!
May 09 2005