Why allow initializers of non-static members that allocate?

Mike Parker aldacron at gmail.com
Fri Jun 10 07:49:43 UTC 2022


On Friday, 10 June 2022 at 07:46:36 UTC, Mike Parker wrote:

>
> I think this is a case where having a warning that's on by 
> default, and which can be explicitly disabled, is useful. "Blah 
> blah .init blah blah. See link-to-something-in-docs. Is this 
> what you intended?"

And it *is* documented:

> Struct fields are by default initialized to whatever the 
> Initializer for the field is, and if none is supplied, to the 
> default initializer for the field's type.
> The default initializers are evaluated at compile time.

https://dlang.org/spec/struct.html#default_struct_init


More information about the Digitalmars-d-learn mailing list