Adding empty static this() causes exception

nkm1 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 12 15:24:05 PDT 2017


On Tuesday, 12 September 2017 at 19:59:52 UTC, Joseph wrote:
> The compiler shouldn't arbitrarily force one to make arbitrary 
> decisions that waste time and money.

You might want to educate yourself about arbitrary decisions that 
waste time and money: 
https://isocpp.org/wiki/faq/ctors#static-init-order

>
> My solution was to turn those static this's in to functions and 
> simply call them at at the start of main(). Same effect yet 
> doesn't crash. The compiler should only run the static this's 
> once per module load anyways, right? If it is such a problem 
> then some way around it should be included: @force static 
> this() { } ?

There is a way, turn static this's into functions and simply call 
them at the start of main().

> The compiler shouldn't make assumptions about the code I write 
> and always choose the worse case, it becomes an unfriendly 
> relationship at that point.

If you want C++, you know where to find it, although I wouldn't 
exactly call it "friendly".




More information about the Digitalmars-d-learn mailing list