Whats going on with this?

Steven Schveighoffer schveiguy at gmail.com
Sat Oct 3 14:41:14 UTC 2020


On 10/3/20 6:52 AM, claptrap wrote:
> On Saturday, 3 October 2020 at 00:15:02 UTC, Steven Schveighoffer wrote:
>> On 10/2/20 7:28 PM, claptrap wrote:
>>
>>> Why would putting in the writeln cause it to fail? Is it maybe trying 
>>> to create the foo at compile time?
>>>
>>
>> Yes, it is. Any static initialization of static variables happens at 
>> compile-time.
>>
>> https://dlang.org/spec/declaration.html#global_static_init
>>
> 
> Ah.. ok, any idea why this works?
> 
> Foo foo = [300,300];

Yeah, it's calling the constructor. I agree with Adam, there's nothing 
in the spec that talks about this that I can find.

-Steve


More information about the Digitalmars-d-learn mailing list