-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
[PoC] In-place struct initialization #8460
Conversation
|
Thanks for your pull request, @wilzbach! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8460" |
|
Why do you need a new expression type? |
|
Can't you just use the existing StructLiteralExp and add the fields fields you want + a bool field that tells you if StructLiteralExp is used for in-place initialization? |
|
status? |
@andralex there's a DIP that hasn't been approved. Personally I don't think a DIP is needed. But we seem to disagree on the syntax. |
This is a working PoC, but there are multiple ways to integrate this feature in the D grammar (see the DIP for more details) and as there was never a consensus on which syntax to use. @andralex what are your thoughts on the syntax for this? |
4837f97
to
8ffce92
Compare
|
This has been superseded by named arguments, which have been implemented for struct constructors. |
So this is my WIP hack to have in-place struct initialization into DMD.
As during the parsing stage we don't have much information about the struct and can only parse a
StructInitializer, I created an intermediateStructLiteralExp2that will be converted into aStructLiteralExpduring expression semantic.I would like to have a more elegant solution and this still needs a lot of work, but it already passes the test suite for the common cases of this DIP and I thought it's good to show that it's possible to do this in dmd for submitting the DIP. Also I get to see what the CIs say.
What's in-place struct initialization?
Full DIP: dlang/DIPs#71
tl;dr: