<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 11, 2016, at 10:21 AM, Janosch Hildebrand <<a href="mailto:jnosh@jnosh.com" class="">jnosh@jnosh.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Hi Matthew,</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Just a few quick comments:</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">propertylist:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Not a big fan of the name either, `propertyalias` came to mind but that sounds like it's only for a single property.</div></div></blockquote><div><br class=""></div><div>If you think of something better please let me know!</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">@propertylist:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I think this is mostly redundant and the proposal would be improved by its removal.</div></div></blockquote><div><br class=""></div><div>Removing it would require a redundant list of property names in some cases. Why do you think that is better?</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">propertylist syntax:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I don't think the current syntax. Using `:` feels wrong as I instinctively expect a type to it's right.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">How about: `propertylist fooProps = (aProp, bProp)`</div></div></blockquote><div><br class=""></div><div>That syntax could work.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">Default values in propertylist:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Strongly against this. Only applicable to initializer use case and feels generally out of place.</div></div></blockquote><div><br class=""></div><div>It is extremely important to the initializer use case. There is no way to provide a default for `let` properties in the initializer without allowing this. I would not have written this proposal at all if it weren’t for a desire to improvise the initializer use case.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I have also looked at the other two related proposals but I'm far from having a final opinion on any of the three.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I'm also posting my current very short and very rough impressions of the three related proposals here as I feel they are strongly related and I don't have enough to say about the other two to really justify separate posts:</div></div></blockquote><div><br class=""></div><div>Thanks. I appreciate your feedback!</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">Parameter forwarding:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">This is the proposal I like the least. I'm not a fan of the syntax and it mostly saves some minor typing at the cost immediately knowing what the actual arguments are.</div></div></blockquote><div><br class=""></div><div>Have you used a language with a similar feature (such as tuple packing and unpacking in a dynamic language)? It is quite useful. IMO, removing the clutter of each argument, type, and default value makes it much more clear that simple forwarding is happening.</div><div><br class=""></div><div>The complete parameter list would still appear in generated documentation, autocomplete, etc. An IDE could also provide an option to view the full parameter list in the function declaration itself.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">Partial initializers:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">My dislike of parameter forwarding carries over to this but otherwise I find the basic idea quite nice.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">My bigger issue here is that I currently don't see a huge use case for this that isn't already served by initializer delegation. Yes this seems to cover additional cases but I'm not sure it justifies it's existence. It makes a lot more sense when considered as part of the memberwise initialization trifecta with parameter forwarding but like I said that's the part I don't really like.</div></div></blockquote><div><br class=""></div><div>Initializer delegation requires the initializer you call to be a complete initializer. It is not uncommon to have more than one designated initializer that need to share initialization logic. There are techniques to factor out some of this logic today, but it would be much easier with partial initializers. </div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><b class="">Property Lists:</b></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Like with partial initializers I find this to be an interesting idea and this seems to have other potential use cases apart from memberwise initialization. Then again I'm unsure if this exact proposal is the way to go here. I'd really prefer to see more abstract discussion of this idea before committing to any specifics.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Particularly here but also in general for all three proposals I feel that we might be better served by letting the language form further and waiting for more general pieces to fall into place before charging ahead in these areas. None of these require stopgap solutions from my point of view and I at least feel like I could evaluate this much better once I have an idea of what Swift is going to look like at version 4, 5, ...</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">From reading the Swift team's comments it seems like future improvements like variadic generics might make a potential difference here and I imagine the macro system might as well.</div></div></blockquote><div><br class=""></div><div>These proposals are partly a response to the comments Dave and Joe made about building on more general underlying features.</div><div><br class=""></div><div>Partial initializers are a feature that would need to stand on its own, it would not be enabled by any other features. As noted in the proposal, it might actually help to prepare the initialization model to support initialization of extensions and protocols with stored properties.</div><div><br class=""></div><div>I don’t believe variadic generics would cover the full set of forwarding capabilities I would like to see. Particularly forwarding of default values, but also forwarding a subset of parameters. I know you are not a fan of the forwarding idea so that may not matter much to you.</div><div><br class=""></div><div>The property list idea could probably be implemented with a powerful-enough macro system. My opinion is that it would be nice to solve this problem in Swift 3 if possible. The feature could be replaced by a macro down the road if it becomes possible to write it that way.</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I hope this doesn't sound too negative, you clearly invested a significant amount of work into these proposals and I value the effort. It helps me better understand the problems people see and what potential solutions might look like and stirs a lot of healthy discussion.</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">So don't let yourself be discouraged if I don't feel that changes in this area are required just yet :-)</div></div></blockquote><div><br class=""></div><div>That’s a fair opinion. The discussion has been healthy indeed! IMO it has at least validated that there is broad support for doing something to address these problems. </div><div><br class=""></div><div>One of the big critiques of the Flexible Memberwise Initialization proposal was that it wasn’t powerful enough to support all the use cases people want to solve. I think there is a lot of demand to solve these problems and many people would like to see them solved in Swift 3. </div><div><br class=""></div><div>Matthew</div><br class=""><blockquote type="cite" class=""><div class=""><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">- Janosch</div><br class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" class=""><div class="">On 11 Jan 2016, at 04:44, Matthew Johnson via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">I have always considered the Flexible Memberwise Initialization proposal to be just a first step (as evidenced by the many future enhancements it discussed). Its review has inspired new ideas and helped to shape my vision of the best long-term solution. My final thoughts about the review can be found here: <a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/006176.html" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160104/006176.html</a></div><div class=""><br class=""></div><div class="">Property lists is the third in a series of three proposals describing general features that can work together to form a complete solution.</div><div class=""><br class=""></div><div class=""><div class="">The proposal drafts can be found at the following links:</div><div class=""><br class=""></div><div class="">* <b class="">Parameter forwarding:</b> <a href="https://github.com/anandabits/swift-evolution/blob/parameter-forwarding/proposals/NNNN-parameter-forwarding.md" class="">https://github.com/anandabits/swift-evolution/blob/parameter-forwarding/proposals/NNNN-parameter-forwarding.md</a></div><div class="">* <b class="">Partial initializers:</b> <a href="https://github.com/anandabits/swift-evolution/blob/partial-initializers/proposals/NNNN-partial-initializers.md" class="">https://github.com/anandabits/swift-evolution/blob/partial-initializers/proposals/NNNN-partial-initializers.md</a></div><div class="">* <b class="">Property lists:</b> <a href="https://github.com/anandabits/swift-evolution/blob/property-lists/proposals/NNNN-property-lists.md" class="">https://github.com/anandabits/swift-evolution/blob/property-lists/proposals/NNNN-property-lists.md</a></div></div><div class=""><br class=""></div><div class="">Matthew</div><div class=""><h1 id="propertylists" class="" style="font-size: 37px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Property Lists</h1><ul class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">Proposal: <a href="https://github.com/apple/swift-evolution/blob/master/proposals/NNNN-property-lists.md" class="" style="color: rgb(13, 110, 161); text-decoration: none; -webkit-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out;">SE-NNNN</a></li><li class="" style="font-size: 17px;">Author(s): <a href="https://github.com/anandabits" class="" style="color: rgb(13, 110, 161); text-decoration: none; -webkit-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out;">Matthew Johnson</a></li><li class="" style="font-size: 17px;">Status: <strong class="" style="line-height: 1;">Awaiting review</strong></li><li class="" style="font-size: 17px;">Review manager: TBD</li></ul><h2 id="introduction" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Introduction</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">This proposal introduces the <code class="" style="line-height: 1;">propertylist</code> declaration. Property lists provide concise syntactic sugar for declaring memberwise partial initializers and memberwise computed tuple properties.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">NOTE: I do not love the name “property lists” for the feature or the keyword but haven’t thought of anything better. Suggestions are welcome.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">Swift-evolution thread: <a href="https://lists.swift.org/pipermail/swift-evolution" class="" style="color: rgb(13, 110, 161); text-decoration: none; -webkit-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out;">Proposal Draft: Property Lists</a></p><h2 id="motivation" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Motivation</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">I believe the review of the <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0018-flexible-memberwise-initialization.md" class="" style="color: rgb(13, 110, 161); text-decoration: none; -webkit-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out;">Flexible Memberwise Initialization</a> proposal demonstrated a strong demand for concise yet flexible memberwise initialization. The discussion highlighted several areas where that proposal fell short:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">Clarity regarding which parameters receive memberwise initialization.</li><li class="" style="font-size: 17px;">Control over which parameters receive memberwise initialization.</li><li class="" style="font-size: 17px;">Control over specific memberwise parameter ordering.</li><li class="" style="font-size: 17px;">Control over parameter labels.</li><li class="" style="font-size: 17px;">Control over default parameter values, especially for <code class="" style="line-height: 1;">let</code> properties.</li><li class="" style="font-size: 17px;">It is a very narrow, special case feature.</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">This proposal builds on the <a href="https://github.com/anandabits/swift-evolution/blob/partial-initializers/proposals/NNNN-partial-initializers.md" class="" style="color: rgb(13, 110, 161); text-decoration: none; -webkit-transition: color 0.2s ease-in-out; transition: color 0.2s ease-in-out;">Partial Initializer</a> proposal to solve these problems using a more general underlying mechanism. It enables truly flexible memberwise initialization. </p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">Property lists also support other memberwise features, beginning with memberwise computed tuple properties.</p><h2 id="proposedsolution" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Proposed solution</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">There are two ways to specify a property list. The basic mechanism is a property list declaration that looks as follows: </p><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"> propertylist configProperties: aPropName, customLabel anotherPropName = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span></code></pre><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">All properties mentioned in the property list declaration must be visible at the site of the declaration.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">A <code class="" style="line-height: 1;">propertylist</code> attribute also exists for property declarations to support cases where a list of property declarations should also be treated as a property list:</p><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"> @propertylist(aPropertyListIdentifier) <span class="hljs-keyword" style="font-weight: bold;">let</span> prop1, prop2: <span class="hljs-type">Int</span></code></pre><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">A property list can contain any kind of property, including those with behaviors. However, when certain kinds of properties are included it will not be possible to synthesize a partial memberwise initializer and / or a setter for the computed tuple property.</p><h3 id="synthesizedelements" class="" style="color: rgb(17, 17, 17); margin: 21px 0px; font-size: 20px; line-height: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Synthesized elements</h3><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">A typealias will always be synthesized:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">It will have a name matching the identifier of the property list, with the first character transformed to upper case.</li><li class="" style="font-size: 17px;">It will be a tuple type containing labels and types matching those specified in the property list.</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">A computed tuple property will always be synthesized:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">It will always include a getter.</li><li class="" style="font-size: 17px;">Visibility of the getter will match the visibility of the least visible getter.</li><li class="" style="font-size: 17px;">It will contain a setter as long as all of the properties are settable.</li><li class="" style="font-size: 17px;">Visibility of the setter will match the visibility of the least visible setter.</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">A paritial initializer will only be generated if:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">All properties are stored properties.</li><li class="" style="font-size: 17px;">None are <code class="" style="line-height: 1;">let</code> properties with an initial value.</li><li class="" style="font-size: 17px;">None have a behavior which is incompatible with phase 1 initialization.</li><li class="" style="font-size: 17px;">Visibility of the partial initializer will match the least visible setter for structs. Partial initializers for classes are always private (as specified by the partial initializer proposal).</li><li class="" style="font-size: 17px;">The property list is declared in the main body of the type, not an extension, <strong class="" style="line-height: 1;">unless</strong> the type is a struct.</li><li class="" style="font-size: 17px;">If stored properties are allowed in extensions and / or protocols in the future, all properties included in the list must be declared within the same body as the property list for a partial initializer to be synthesized (either the main body of the type or the body of the same extension or same protocol).</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">The structure of the synthesized elements is as follows:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">Ordering of partial initializer parameters and tuple members will match the order of the property list declaration.</li><li class="" style="font-size: 17px;">The external parameter labels and tuple labels will match the label specified in the property list if it exists and the property name otherwise.</li><li class="" style="font-size: 17px;">The default value for partial initializer parameters will be the default value specified in the property list if it exists and the initial value of the property otherwise (if that exists). If neither exist the parameter will not have a default value.</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">Visibility of a synthesized members is capped at <code class="" style="line-height: 1;">internal</code> unless <code class="" style="line-height: 1;">public</code> is explicitly specified. If <code class="" style="line-height: 1;">public</code> (or <code class="" style="line-height: 1;">internal</code>) is explicitly specified, all properties referenced must have getter and setter visibility of <strong class="" style="line-height: 1;">at least</strong> the specified access level or a compiler error will result.</p><h3 id="examples" class="" style="color: rgb(17, 17, 17); margin: 21px 0px; font-size: 20px; line-height: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Examples</h3><h4 id="basicexample" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Basic example</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-keyword" style="font-weight: bold;">public</span> <span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
<span class="hljs-keyword" style="font-weight: bold;">public</span> <span class="hljs-keyword" style="font-weight: bold;">var</span> s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>
<span class="hljs-keyword" style="font-weight: bold;">public</span> <span class="hljs-keyword" style="font-weight: bold;">var</span> d: <span class="hljs-type">Double</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares:</span>
<span class="hljs-keyword" style="font-weight: bold;">public</span> propertylist custom: dLabel d = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>, s
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">public</span> <span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (dLabel: <span class="hljs-type">Double</span>, s: <span class="hljs-type">String</span>)
<span class="hljs-keyword" style="font-weight: bold;">public</span> <span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (dLabel: d, s: s) }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { (d, s) = newValue }
}
<span class="hljs-keyword" style="font-weight: bold;">public</span> partial <span class="hljs-keyword" style="font-weight: bold;">init</span> custom(dlabel d: <span class="hljs-type">Double</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>, s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>) {
<span class="hljs-keyword" style="font-weight: bold;">self</span>.d = d
<span class="hljs-keyword" style="font-weight: bold;">self</span>.s = s
}
}</code></pre><h4 id="includingaletwithainitialvalue" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Including a let with a initial value</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
<span class="hljs-keyword" style="font-weight: bold;">let</span> s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>
<span class="hljs-keyword" style="font-weight: bold;">var</span> d: <span class="hljs-type">Double</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares:</span>
propertylist custom: dLabel d, s
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (dLabel: <span class="hljs-type">Double</span>, s: <span class="hljs-type">String</span>)
<span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (dLabel: d, s: s) }
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// <span class="hljs-doctag">NOTE:</span> no setter because a `let` was included</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// and no partial initializer because the `let` </span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// has an initial value.</span>
}</code></pre><h4 id="includingalazyproperty" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Including a lazy property</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span>
<span class="hljs-keyword" style="font-weight: bold;">var</span> s: <span class="hljs-type">String</span>
<span class="hljs-built_in" style="color: rgb(0, 134, 179);">lazy</span> <span class="hljs-keyword" style="font-weight: bold;">var</span> d: <span class="hljs-type">Double</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares:</span>
propertylist custom: dLabel d, s
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (dLabel: <span class="hljs-type">Double</span>, s: <span class="hljs-type">String</span>)
<span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (dLabel: d, s: s) }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { (d, s) = newValue }
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// <span class="hljs-doctag">NOTE:</span> no partial initializer because a `lazy var` was included.</span>
}</code></pre><h4 id="includingavarwithaprivatesetter" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Including a <code class="" style="line-height: 1;">var</code> with a private setter</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span>
<span class="hljs-keyword" style="font-weight: bold;">var</span> s: <span class="hljs-type">String</span>
<span class="hljs-keyword" style="font-weight: bold;">private</span>(<span class="hljs-keyword" style="font-weight: bold;">set</span>) <span class="hljs-keyword" style="font-weight: bold;">var</span> d: <span class="hljs-type">Double</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares:</span>
propertylist custom: dLabel d, s = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (dLabel: <span class="hljs-type">Double</span>, s: <span class="hljs-type">String</span>)
<span class="hljs-keyword" style="font-weight: bold;">private</span>(<span class="hljs-keyword" style="font-weight: bold;">set</span>) <span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (dLabel: d, s: s) }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { (d, s) = newValue }
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// <span class="hljs-doctag">NOTE:</span> The initial value for `d` is used as a default </span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// parameter value because a different default parameter value </span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// was not specified.</span>
<span class="hljs-keyword" style="font-weight: bold;">private</span> partial <span class="hljs-keyword" style="font-weight: bold;">init</span> custom(dlabel d: <span class="hljs-type">Double</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>, s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>) {
<span class="hljs-keyword" style="font-weight: bold;">self</span>.d = d
<span class="hljs-keyword" style="font-weight: bold;">self</span>.s = s
}
}</code></pre><h4 id="includingacomputedproperty" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Including a computed property</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span>
<span class="hljs-keyword" style="font-weight: bold;">var</span> s: <span class="hljs-type">String</span>
<span class="hljs-keyword" style="font-weight: bold;">var</span> d: <span class="hljs-type">Double</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> getValueFromSomewhere() }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { storeValueSomewhere(newValue) }
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares:</span>
propertylist custom: dLabel d, s
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (dLabel: <span class="hljs-type">Double</span>, s: <span class="hljs-type">String</span>)
<span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (dLabel: d, s: s) }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { (d, s) = newValue }
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// <span class="hljs-doctag">NOTE:</span> no partial initializer because a computed property was included.</span>
}</code></pre><h4 id="usingthepropertylistattribute" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Using the <code class="" style="line-height: 1;">@propertylist</code> attribute</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
@propertylist(custom) <span class="hljs-keyword" style="font-weight: bold;">var</span> s: <span class="hljs-type">String</span>, d: <span class="hljs-type">Double</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
<span class="hljs-keyword" style="font-weight: bold;">private</span> <span class="hljs-keyword" style="font-weight: bold;">let</span> i: <span class="hljs-type">Int</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes:</span>
<span class="hljs-keyword" style="font-weight: bold;">typealias</span> <span class="hljs-type">Custom</span> = (s: <span class="hljs-type">String</span>, d: <span class="hljs-type">Double</span>)
<span class="hljs-keyword" style="font-weight: bold;">var</span> custom: <span class="hljs-type">Custom</span> {
<span class="hljs-keyword" style="font-weight: bold;">get</span> { <span class="hljs-keyword" style="font-weight: bold;">return</span> (s: s, d: d) }
<span class="hljs-keyword" style="font-weight: bold;">set</span> { (s, d) = newValue }
}
partial <span class="hljs-keyword" style="font-weight: bold;">init</span> custom(s: <span class="hljs-type">String</span>, d: <span class="hljs-type">Double</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>) {
<span class="hljs-keyword" style="font-weight: bold;">self</span>.s = s
<span class="hljs-keyword" style="font-weight: bold;">self</span>.d = d
}
}</code></pre><h4 id="usingapropertylistdeclarationformemberwiseintialization" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Using a property list declaration for memberwise intialization</h4><pre class="" style="margin-top: 21px; margin-bottom: 21px; tab-size: 4; color: rgb(17, 17, 17); font-size: 15px; background-color: rgb(248, 248, 248);"><code class="swift hljs" style="line-height: inherit; display: block; padding: 0.5em; color: rgb(51, 51, 51); height: auto;"><span class="hljs-class"><span class="hljs-keyword" style="font-weight: bold;">struct</span> <span class="hljs-title" style="color: rgb(68, 85, 136); font-weight: bold;">S</span> </span>{
<span class="hljs-keyword" style="font-weight: bold;">var</span> x, y, z: <span class="hljs-type">Int</span>
<span class="hljs-keyword" style="font-weight: bold;">let</span> s: <span class="hljs-type">String</span>
<span class="hljs-keyword" style="font-weight: bold;">let</span> d: <span class="hljs-type">Double</span>
propertylist randomGroup aString s = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>, anInt x = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// user declares</span>
<span class="hljs-keyword" style="font-weight: bold;">init</span>(...randomGroup) {
y = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
z = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
d = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
}
<span class="hljs-comment" style="color: rgb(153, 153, 136); font-style: italic;">// compiler synthesizes</span>
partial <span class="hljs-keyword" style="font-weight: bold;">init</span> randomGroup(aString s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>, anInt x: <span class="hljs-type">Int</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>) {
<span class="hljs-keyword" style="font-weight: bold;">self</span>.s = s
<span class="hljs-keyword" style="font-weight: bold;">self</span>.x = x
}
<span class="hljs-keyword" style="font-weight: bold;">init</span>(aString s: <span class="hljs-type">String</span> = <span class="hljs-string" style="color: rgb(221, 17, 68);">"hello"</span>, anInt x: <span class="hljs-type">Int</span> = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>) {
randomGroup.<span class="hljs-keyword" style="font-weight: bold;">init</span>(aString: s, anInt: x)
y = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
z = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
d = <span class="hljs-number" style="color: rgb(0, 153, 153);">42</span>
}
}</code></pre><h4 id="usingthepropertylistattributeformemberwiseintialization" class="" style="color: rgb(17, 17, 17); font-size: 20px; line-height: 21px; margin-top: 21px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Using the property list attribute for memberwise intialization</h4><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">```swift<br class="">struct S {<br class="">@propertylist(declaredTogether) var x, y, z: Int<br class="">let s: String<br class="">let d: Double</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">// user declares:<br class="">init(…declaredTogether) {<br class="">s = “hello”<br class="">d = 42<br class="">}</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">// compiler synthesizes:<br class="">partial init declaredTogether(x: Int, y: Int, z: Int) {<br class="">self.x = x<br class="">self.y = y<br class="">self.z = z<br class="">} init(x: Int, y: Int, z: Int) {<br class="">declaredTogether.init(x: Int, y: Int, z: Int)<br class="">s = “hello”<br class="">d = 42<br class="">}</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">}</p><h3 id="implicitpropertylists" class="" style="color: rgb(17, 17, 17); margin: 21px 0px; font-size: 20px; line-height: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Implicit property lists</h3><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">It may be desirable to have several implicit property lists available, such as one that includes all properties of the type. Properties would appear in any implicit property lists in declaration order.</p><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">The specific details of what implicit property lists should be available and what they should be called is a good topic for bikeshedding.</p><h2 id="detaileddesign" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Detailed design</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">TODO but should fall out pretty clearly from the proposed solution</p><h2 id="impactonexistingcode" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Impact on existing code</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">This is a strictly additive change. It has no impact on existing code.</p><h2 id="alternativesconsidered" class="" style="color: rgb(17, 17, 17); font-size: 27px; line-height: 42px; margin-top: 42px; margin-bottom: 21px; font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif;">Alternatives considered</h2><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">We could live without this syntactic sugar. There are several reasons the language is better with it:</p><ol class="" style="margin-top: 21px; margin-bottom: 21px; padding-left: 1.5em; color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; font-size: 15px;"><li class="" style="font-size: 17px;">It is much more convenient than manually writing memberwise partial intializers. It does not include any unnecessary information, thus making the details more clear.</li><li class="" style="font-size: 17px;">It gives us the memberwise computed tuple properties for free. This would would not be possible when writing memberwise partial initializers manually.</li><li class="" style="font-size: 17px;">It scales to any new memberwise features that might make sense for a type.</li></ol><p class="" style="color: rgb(17, 17, 17); font-family: 'Helvetica Neue', Helvetica, Arial, Verdana, sans-serif; word-wrap: break-word; margin: 1.3125em 0px; font-size: 1.1429em; line-height: 1.3125em;">As always, the <code class="" style="line-height: 1;">propertylist</code> keyword is game for bikeshedding. The use of <code class="" style="line-height: 1;">:</code> to separate the identifier from the list of properties could also be game for bikeshedding. Also, as mentioned previously, the implicit property lists are game for bikeshedding.</p></div><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=nns-2FBjd8vUIyZmnkfXvcBIDOLRP1cU9oMCgK1G0q49droKblbQr9S3sTlldXXrtwvqx1VR59mJSLxuUAuW8GZTKsEf-2Bp4aRAhPrFmuvx5iaGfq1yKzeCKCoRdYFD0w43wOI9GCVXKZzQDzD3qJsgeQWYbfs94ChG-2BIx5e-2Fy2BLr4NZ42DiCyRSKWwijHimwiQIMYHl6A0uEMBt01o-2BbxrA-3D-3D" alt="" width="1" height="1" border="0" class="" style="height: 1px !important; width: 1px !important; border-width: 0px !important; margin: 0px !important; padding: 0px !important;"></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div></div></blockquote></div><br class=""></body></html>