digitalmars.D.bugs - new definition of static?
- Sean Kelly (11/11) Jul 19 2004 In 0.95, this fails to compile with the error "test.d(15): non-constant
- Kris (9/20) Jul 19 2004 I'd be willing to bet that it'd work if you split the declaration from t...
- Sean Kelly (7/12) Jul 19 2004 You're right, that works. How incredibly odd. But this new syntax make...
- Kris (9/24) Jul 19 2004 I do this kind of thing in a static constructor; but the language/compil...
- Walter (8/18) Aug 15 2004 exceptions
In 0.95, this fails to compile with the error "test.d(15): non-constant expression new E" int main() { class E : Exception { this() { super( "" ); } } static E e = new E(); return 0; } I had been using this technique so I only had to construct internal exceptions once. Is there a new method I can use to do the same thing, or is this a bug? Sean
Jul 19 2004
I'd be willing to bet that it'd work if you split the declaration from the assignment: static E e; e = new E; Sucks? Yes ... "Sean Kelly" <sean f4.ca> wrote in message news:cdh1j6$jto$1 digitaldaemon.com...In 0.95, this fails to compile with the error "test.d(15): non-constant expression new E" int main() { class E : Exception { this() { super( "" ); } } static E e = new E(); return 0; } I had been using this technique so I only had to construct internalexceptionsonce. Is there a new method I can use to do the same thing, or is this abug?Sean
Jul 19 2004
In article <cdh2hh$ker$1 digitaldaemon.com>, Kris says...I'd be willing to bet that it'd work if you split the declaration from the assignment: static E e; e = new E; Sucks? Yes ...You're right, that works. How incredibly odd. But this new syntax makes it look like e will be initialized every time the function is called, which is not what I want. And I'd prefer not to have to put in a bunch of: if( !e ) e = new E(); calls... perhaps this will be fixed in 0.96? Sean
Jul 19 2004
I do this kind of thing in a static constructor; but the language/compiler would ideally support a one-time assignment to something like a "static final", or whatever Walter would prefer to call it. - Kris "Sean Kelly" <sean f4.ca> wrote in message news:cdh3hl$kou$1 digitaldaemon.com...In article <cdh2hh$ker$1 digitaldaemon.com>, Kris says...theI'd be willing to bet that it'd work if you split the declaration fromitassignment: static E e; e = new E; Sucks? Yes ...You're right, that works. How incredibly odd. But this new syntax makeslook like e will be initialized every time the function is called, whichis notwhat I want. And I'd prefer not to have to put in a bunch of: if( !e ) e = new E(); calls... perhaps this will be fixed in 0.96? Sean
Jul 19 2004
"Sean Kelly" <sean f4.ca> wrote in message news:cdh1j6$jto$1 digitaldaemon.com...In 0.95, this fails to compile with the error "test.d(15): non-constant expression new E" int main() { class E : Exception { this() { super( "" ); } } static E e = new E(); return 0; } I had been using this technique so I only had to construct internalexceptionsonce. Is there a new method I can use to do the same thing, or is this abug? D doesn't do the C++ thing of wrapping dynamic initializers for local statics in a conditional. You'll need to do it manually, as in: static E e; if (!e) e = new E();
Aug 15 2004