In-place memberwise initializers #1890
tothambrus11
started this conversation in
Language design
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
TODO summarize existing approaches (see Slack).
Having an
inplaceparameter passing convention specifically for initializers could simplify the semantics and compilation ofmemberwise init, and make it expressible with a user-defined initializer. Specifically,memberwise initwould desugar to a regular initializer with all its parameters passed via theinplaceconvention.Consider the following code in Hylo:
This would be lowered to an in-place initialization on the call site, followed by a call to the init function, which now only has y as a parameter:
We can add knobs to control what we promise about the ABI:
inplace memberwise initorsinking memberwise init- the latter would accept members as sink arguments, requiringMovableconformance. The former locks in that the current stored properties remain stored properties forever (though it allows reordering and adding new stored properties). Whether which one should be the implicit default is to be decided.noncustom memberwise init: Indicate if want to promise that we won't want to rewrite the initializer to a user-defined initializer with custom initializer body. This would prevent us from adding extra fields without breaking ABI, since we would need to initialize those somewhere.All reactions