Why allow initializers of non-static members that allocate?
Bastiaan Veelo
Bastiaan at Veelo.net
Fri Jun 10 08:14:27 UTC 2022
On Friday, 10 June 2022 at 07:49:43 UTC, Mike Parker wrote:
> 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
Yes, that section I find open for interpretation, because I don't
think pointer values can be determined at compiler time. I assume
S.init is constructed at program initialization, which is then
blitted into any new instance of S.
-- Bastiaan.
More information about the Digitalmars-d-learn
mailing list