Whats going on with this?

Daniel Kozak kozzi11 at gmail.com
Sat Oct 3 20:40:54 UTC 2020


On Sat, Oct 3, 2020 at 4:45 PM Steven Schveighoffer via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> 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
>

I would say it is here you just need to read it carefully:

https://dlang.org/spec/struct.html#static_struct_init
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20201003/3adead4f/attachment.htm>


More information about the Digitalmars-d-learn mailing list