-
-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The spec should not refer to default initialization as default construction when discussing disabling it #4146
Labels
Comments
nick (@ntrel) commented on 2024-10-12T13:12:29Z> As default construction is not a thing with structs
What about initializing the context pointer?
https://dlang.org/spec/property.html#init-vs-construction |
issues.dlang (@jmdavis) commented on 2024-10-12T14:25:42Z(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. |
issues.dlang (@jmdavis) commented on 2024-10-13T09:48:41ZI've e-mailed Walter for clarification on this. It appears that the compiler's error messages are in agreement with the terminology used in the spec. So, the current terminology may very well be what Walter wants to use in spite of the fact that we don't have default constructors, and we normally talk about structs being default-initialized rather than default-constructed, because we don't have default constructors, and the mechanics are different. |
issues.dlang (@jmdavis) commented on 2024-10-14T19:31:46ZWalter agreed to updating the terminology to refer to default initialization instead of default construction. I'll open a separate issue for the compiler messages. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Jonathan M Davis (@jmdavis) reported this on 2024-10-11T18:32:54Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=24805
CC List
Description
The text was updated successfully, but these errors were encountered: