digitalmars.D.bugs - can't declare and initialize a static in the same expression
- Sean Kelly (10/10) Jul 30 2004 Shouldn't this be legal?
- Walter (4/14) Jul 30 2004 No, all static initializers need to be resolvable at compile time. To do...
Shouldn't this be legal?
D:\code\d>type test.d
class A {}
int main()
{
static A a = new A();
return 0;
}
D:\code\d>dmd test.d
test.d(5): non-constant expression new A
Jul 30 2004
"Sean Kelly" <sean f4.ca> wrote in message
news:cee7bb$mf$1 digitaldaemon.com...
Shouldn't this be legal?
D:\code\d>type test.d
class A {}
int main()
{
static A a = new A();
return 0;
}
D:\code\d>dmd test.d
test.d(5): non-constant expression new A
No, all static initializers need to be resolvable at compile time. To do run
time initialization, use a static constructor.
Jul 30 2004








"Walter" <newshound digitalmars.com>