[Issue 24805] The spec should not refer to default initialization as default construction when discussing disabling it

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Oct 12 14:25:42 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=24805

--- Comment #2 from Jonathan M Davis <issues.dlang at jmdavisProg.com> ---
(In reply to Nick Treleaven from comment #1)
> > As default construction is not a thing with structs
> 
> What about initializing the context pointer?
> 
> https://dlang.org/spec/property.html#init-vs-construction

D structs do not have default construction, and it is always incorrect to refer
to anything that happens with them as default construction. They have default
initialization, which normally is simply blitting the init value, but with
non-static structs that then have a context pointer to their enclosing scope,
some additional initialization code is run when they're initialized to also set
their context pointer, making it so that there is a difference between that and
directly initializing the struct with its init value in those specific cases.

However, there still is no default constructor or default construction, and
referring to it that way is just going to confuse people. Default constructors
are a C++ thing, and even if we were to add them to D structs at some point,
the default initialization that currently occurs would still occur prior to the
default constructor being called (since that's required for the type to be in a
valid state; it's also what happens with classes), so there would still be a
difference between default initialization and default construction.

--


More information about the Digitalmars-d-bugs mailing list