<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 20, 2016, at 8:48 PM, Jordan Rose &lt;<a href="mailto:jordan_rose@apple.com" class="">jordan_rose@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hm. Some comments:</div></div></div></blockquote><div><br class=""></div><div>Thanks for providing lots of feedback!</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">This proposal&nbsp;<b class="">does not</b>&nbsp;introduce extensions with stored properties, however partial initialization is closely&nbsp;related to that topic. Class extensions with stored properties would be required to have an extension initializer.&nbsp;That extension initializer would effectively be treated as a partial initializer by designated initializers of the&nbsp;class.&nbsp;<br class=""></blockquote><div class=""><br class=""></div>I feel like most "extensions with stored properties" proposals have to cover extensions from another module, but maybe those properties are required to be lazy or something.<br class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class="">3. Partial initializers and initialization methods may include an access control modifier specifying their&nbsp;visibility.</blockquote><br class=""></div></div><div class="">I'm a little concerned about exposing these things publicly: there's no point if the struct or class has non-public fields (because new non-delegating initializers can't initialize the non-public fields), and by default every struct and class is allowed to <i class="">add</i>&nbsp;non-public fields in new versions of a library. (See the LibraryEvolution.rst doc for more info.) I can kind of see making these private vs. internal, but that has other issues (see below).</div><div class=""><br class=""></div><div class="">Even in the case where all fields are public and the struct promises not to change any fields, you'd <i class="">also</i>&nbsp;have to promise that the partial initializer never changes which properties it's initializing; that's now part of the binary interface of the file. That's unusual for something that behaves like a function; usually the body is not part of the ABI.</div><div class=""><br class=""></div><div class="">I'd much rather just ban 'public' and never have partial inits be part of a library's public interface. Public initializer methods would be presented as plain methods, with no hint of their initializer origins.</div></div></div></blockquote><div><br class=""></div>I have no problem with banning `public`partial inits and only exposing the ordinary method aspect of `public` initializer methods. &nbsp;Unless this is controversial on the core team I will make this change.</div><div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">9. The compiler keeps track of the properties initialized by a partial initializer or initialization method and uses&nbsp;that knowledge when enforcing initialization rules in phase one in the calling initializer.</blockquote><div class=""><br class=""></div>If a struct partial initializer is defined in another file, this would require reading the body of the initializer to determine what variables it initializes. We currently don't type-check any bodies outside of the primary source file when doing a normal, multi-process compilation.</div></div></div></blockquote><div><br class=""></div><div>Are you recommending a same-file requirement? &nbsp;I wouldn’t have a problem with that. &nbsp;I’m trying to keep this proposal as focused as possible and will make any changes necessary to address implementation considerations.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">You're missing a DI condition here in the sub-bullets, which is that the partial initializer must initialize its subset of stored properties on <i class="">all paths</i>.<br class=""></div></div></div></blockquote><div><br class=""></div><div>Agree. &nbsp;I left that implicit but will call it out explicitly.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><div class=""><blockquote type="cite" class="">9 iv. A partial initializer or initialization method can only write to a property once, including&nbsp;var&nbsp;properties.</blockquote><br class=""></div></div><div class="">I'm not sure why John thinks this would make things easier but I'll believe him. Seems like it'd be the same as doing it in phase 1 of an initializer.</div></div></div></blockquote><div><br class=""></div><div>I may have misinterpreted John’s comment. &nbsp;I’m guessing it had to do with releasing the old value if it was set prior to calling the partial init like you mentioned in the other thread. &nbsp;Hopefully he can clarify.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">---</div><div class=""><br class=""></div><div class="">Can an initializer method be overridden? If so, I assume that does <i class="">not</i>&nbsp;override the "initializer" part, just the "method" part? If not, can we require the 'final' to be explicit?</div></div></div></blockquote><div><br class=""></div><div>Good question. &nbsp;I was thinking of them as implicitly `final` but didn’t call that out. &nbsp;If you think they should be explicitly marked `final` I will make that change.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Can the method be marked @objc? 'dynamic'? I would assume "yes", because it's not really different from any other method, but I think it ought to be called out.</div></div></div></blockquote><div><br class=""></div><div>I suppose so if that doesn’t create any implementation challenges around the initializer aspect.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I don't personally like the call syntax but I don't immediately have anything better to offer. I do think that part of this proposal should include naming guidelines for these things.</div></div></div></blockquote><div><br class=""></div><div>I don’t love it but don’t have a better idea either. &nbsp;It’s a good candidate for bike shedding and we might be able to find something better.</div><div><br class=""></div><div>What do you have in mind in terms of naming guidelines? &nbsp;I can imagine UI classes having partial inits like “appearanceProperties” and “animationProperties”, etc. &nbsp;Those names wouldn’t be good for an initializer method though.</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">What happens when you call an init method from phase 2 of initialization? Is that just illegal?</div></div></blockquote><div><br class=""></div><div>Good question. &nbsp;I should have addressed this. &nbsp;Partial initializers should not be callable during phase 2.</div><div><br class=""></div><div>It probably make senses to allow initializer methods to be called during phase 2 using the usual method syntax just like any other method. &nbsp;What do others think?</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">I'm ultimately <i class="">still</i>&nbsp;not convinced that this is the right way to reduce initializer boilerplate (phase 1 duplication between initializers, or shared code between initializers and methods). It again adds complexity to the language, and that added complexity may not be worth the payoff. I'm thinking about someone coming across the construct for the first time: would they understand what it was doing? Would they understand the error messages they would get?</div></div></blockquote><div><br class=""></div><div>What I like about this approach is that it is a general tool for factoring initialization code using techniques similar to those we use in other code. &nbsp;Lots of people do similar things in Objective-C, but in an obviously unsafe way. &nbsp;This would help ease their migration to Swift while helping them do this safely.</div><div><br class=""></div><div>I think the best way to think about the added complexity is to consider the *incremental* complexity and benefit over Swift’s initialization model. &nbsp;I think it is a pretty modest change to understand for those who already understand the existing rules while providing substantial benefit in some cases.</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">(Specifically on that note: "init func" is probably okay because it's a special kind of func, but I think I would personally prefer to keep the 'partial' keyword for partial inits, even though it's technically unnecessary.)</div></div></blockquote><div><br class=""></div><div>I would be happy with whatever syntax the core team thinks is best. &nbsp;I like keeping it more concise but don’t mind `partial` if others like that better.</div><div><br class=""></div><div>It’s just hard to tell what that is with several people involved. &nbsp;Any recommendations on how to handle this when writing a proposal?&nbsp;</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">Sorry for the somewhat scattered thoughts. Hope it's helpful.</div></div></blockquote><div><br class=""></div><div>Absolutely. &nbsp;I really appreciate your feedback!</div><div><br class=""></div><div>-Matthew</div><br class=""><blockquote type="cite" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Jordan</div><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 14, 2016, at 20:08, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I have completed the second draft of my partial initializers proposal (the first really complete draft).&nbsp;<div class=""><div class=""><br class=""></div><div class="">This proposal also includes some discussion of memberwise initialization at John McCall’s request. &nbsp;If anyone would like to continue discussing that topic informally I will be happy to do so, however any such discussion should happen on one of the existing memberwise initialization threads or on a new thread related to that topic. &nbsp;Please do not let that section of the document be a distraction from the partial initializer proposal itself.</div><div class=""><div class=""><br class=""></div><div class="">The new draft can be found here:</div><div class=""><br class=""></div><div class=""><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><div class=""><br class=""></div><div class="">I really appreciate any feedback you have!</div><div class=""><br class=""></div><div class="">-Matthew</div></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=ZEz4qHYnXhPr3bBPu-2FxP4tN3HfWKL-2FtJpqkQ0gkOVSBA1RWShn3xA6rbNnnGhqRjzSX6-2BNfSVBW0qdMNmA-2FD-2Fgbv4NIKoEvXcUesrisuHWNoyLemNRmIRr3mA5zBklkY3-2BR6UWSgK1brFciZQ-2B4fyYXEIsx3-2FRtsVZ4zFwoCYrcRqi-2BeUk62ZnGwyj3lDo5tRVcemwwqvA8tCHG-2F9ee7Zi-2FwBC8j6N7F626lsFgATmc-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" class="">
</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><br class=""></div></blockquote></div><br class=""></div></blockquote></div><br class=""></body></html>