My thoughts & experiences with D so far, as a novice D coder

Nick Sabalausky SeeWebsiteToContactMe at semitwist.com
Wed Mar 27 10:59:13 PDT 2013


On Wed, 27 Mar 2013 10:05:08 -0700
"H. S. Teoh" <hsteoh at quickfur.ath.cx> wrote:

> On Wed, Mar 27, 2013 at 04:34:19PM +0100, Vidar Wahlberg wrote:
> [...]
> 
> > - "Foo foo = new Foo();" for global variables/class members. Now you
> > must "Foo foo; static this() { foo = new Foo(); }".
> 
> Yeah, this is an irksome limitation. Though, it does have the benefit
> of not letting you do something that incurs runtime-cost without being
> explicit about it. Still, it is cumbersome to have to use static
> this() all over the place. It would be nice for the compiler to
> automatically lower such things into implicit ctor calls.
> 

I wouldn't want such things to be implicitly converted to static ctors
unless the cyclic dependency issue was somehow ironed out.

I don't mind initializers of mutable vars being implicitly run at
runtime (that convenience would certainly be nice), but I definitely
don't want "cyclic dependency error" being triggered by something so
innocent-looking.



More information about the Digitalmars-d mailing list