Adding empty static this() causes exception

lobo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Sep 12 15:49:17 PDT 2017


On Tuesday, 12 September 2017 at 19:59:52 UTC, Joseph wrote:
> On Tuesday, 12 September 2017 at 10:08:11 UTC, Moritz Maxeiner 
> wrote:
>> [...]
>
> The compiler shouldn't arbitrarily force one to make arbitrary 
> decisions that waste time and money.
>
> 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() { } ? 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.

Solution is to redesign so there is no cycle because it is 
brittle and generally due to poor architecture. Like goto cyclic 
dependencies are occasionally useful, rarely necessary and avoid 
by default.

bye,
lobo


More information about the Digitalmars-d-learn mailing list