<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=""><div>Hi Tony,</div><div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Sorry to be a (hopefully polite) ogre, but from my perspective, your proposal does not address nor nullify the issues with access modifier levels in Swift, and I don’t think you should be pitching it as a stop-gap. It could make the use of extensions consistent with other similar declarations, but ultimately the access modifier level issues remain.<span class="Apple-converted-space"> </span></span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div>Maybe this will be the case forever: Some people seem to have an affection for such things that goes far beyond my personal requirements, so I have no idea what someone else might come up with (I've already been joking about "cryptographic inheritance", which would allow you to override something only if you know the right transformation for the checksum of your new implementation ;-).</div><div>None the less, the concept is the most versatile I've have seen so far, yet it is less complex than some alternatives.</div><div><br class=""></div><div>Right now, you can have your private properties in type declarations and extensions protected from all other types and extensions in the same file, and people say they want to have this option, so SE-0169 would hurt them.</div><div>Other people want same-file extensions to share private parts, and, at the same time, hide them from alien types in the same file (therefor, they don't want to use fileprivate).</div><div>Those two standpoints could coexist in Swift if we added another access modifier, but even if someone has a better name than "fileprivateButVisibleToSameTypeExtensionsInThisFile", this wouldn't be that nice…</div><div><br class=""></div><div>Nested extensions, on the other hand, would require no new modifiers (actually, it would render fileprivate superfluous), and all you would have to do to have the effect of SE-0169 would be putting your extensions between an existing pair of curly braces, instead of placing them below that block.</div><div>I don't know about your specific issues with access levels, but the ones I have read about can be solved.</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">- Can you clarify for me: does this proposal suggest allowing extensions on the enclosing type to be nested within the type declaration, or within other extensions on the original type? If so, can you please word that more clearly.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div>Both: Whatever is possible outside the curly braces should be possible between them as well (at least I have no spontaneous example for something that should be forbidden).</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">- I would like to see some examples of the proposed syntax included in your proposal (perhaps via a link to the markdown source on GitHub?). Best case and worst case examples would show what impact it will have on readability and file length when someone goes a bit nuts with this feature.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div>No rules will stop people doing stupid things, but I'd rather give the people a tool they could use to harm their codebase, instead of bugging all users of Swift by trying to make it foolproof.</div><div>The linked discussion has an example - I'll attach it here as well, because the HTML has no syntax colouring ;-)</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">- Do you know how much work will be required to implement this change at this stage? Is it feasible within the bounds of the time remaining before Swift 4’s release?</span><br class=""></div></blockquote><div>Well, one major positive aspect of the idea is that there is no need to hurry:</div><div>I have an impression that we are in danger to make decisions without taking enough time to think about their consequences, just because a proposal should be part of the next release.</div><div>Nested extensions wouldn't break anything, so we could just leave this topic alone for now and include it in Swift 5 or 6 — or never, I someone has a better idea in the meantime.</div><div>SE-0169, on the other hand, would be yet another breaking change, and some people think it would harm Swift 4 and possible all versions to come after...</div><div><br class=""></div><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Off-topic suggestion: Using the words “Simply” or “just” when describing work to be done by others is something that you should avoid (unless you’ve already implemented the feature and there’s a PR sitting on GitHub, ready to go). Removing those words allows the sentences to communicate the same ideas, but they no longer trivialise the size/scope of the work to be done during implementation.</span><br class=""></div></blockquote><div>Oh yes, especially that last one — I did not find the fitting word yet, but I have to agree that this part could be interpreted in a way that wasn't intended.</div><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">At this stage, I’m really not sure whether I’d add my support for this proposal were it to go to review, but hopefully my comments are useful.</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><div class="">Well, I expected little more than a handful of comments saying "I like X better" and general disregard, so "I might support it" is already quite positive ;-)</div><div class=""><br class=""></div><div class="">- Tino</div><div class=""><br class=""></div><div class=""><div class=""><div class="" style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div style="margin: 0px; line-height: normal;" class=""><span class="" style="color: rgb(186, 45, 162);">class</span><span class="" style="color: rgb(0, 0, 0);"> MyVC: </span>UIViewController<span class="" style="color: rgb(0, 0, 0);"> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">private</span> <span class="" style="color: rgb(186, 45, 162);">let</span> numberOfSections = <span class="" style="color: rgb(39, 42, 216);">0</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal;" class=""><span class="" style="color: rgb(0, 0, 0);"> </span><span class="" style="color: rgb(186, 45, 162);">extension</span><span class="" style="color: rgb(0, 0, 0);">: </span>UITableViewDataSource<span class="" style="color: rgb(0, 0, 0);"> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>// Skipping the class and assume we want to extend the surrounding type</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">func</span> numberOfSections(in tableView: <span class="" style="color: rgb(112, 61, 170);">UITableView</span>) -> <span class="" style="color: rgb(112, 61, 170);">Int</span> {</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">return</span> numberOfSections</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">func</span> tableView(<span class="" style="color: rgb(186, 45, 162);">_</span> tableView: <span class="" style="color: rgb(112, 61, 170);">UITableView</span>, numberOfRowsInSection section: <span class="" style="color: rgb(112, 61, 170);">Int</span>) -> <span class="" style="color: rgb(112, 61, 170);">Int</span> {</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">return</span> <span class="" style="color: rgb(39, 42, 216);">0</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>private<span class="" style="color: rgb(0, 0, 0);"> </span>extension<span class="" style="color: rgb(0, 0, 0);"> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>// this would contain everything that shoudn't be visible for other extensios</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">var</span> secret: <span class="" style="color: rgb(112, 61, 170);">Int</span> = <span class="" style="color: rgb(39, 42, 216);">0</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>public<span class="" style="color: rgb(0, 0, 0);"> </span>extension<span class="" style="color: rgb(0, 0, 0);"> </span><span class="" style="color: rgb(112, 61, 170);">MyFriendClass</span><span class="" style="color: rgb(0, 0, 0);"> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>// oh, well, I make an exception here for a trustworthy type</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">func</span> checkSecret(of controller: <span class="" style="color: rgb(79, 129, 135);">MyVC</span>) -> <span class="" style="color: rgb(112, 61, 170);">Bool</span> {</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">return</span> controller.secret > <span class="" style="color: rgb(39, 42, 216);">0</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(186, 45, 162);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>private<span class="" style="color: rgb(0, 0, 0);"> </span>extension<span class="" style="color: rgb(0, 0, 0);"> {</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span>// this is so secret, I'm not even allowed to copy it</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> <span class="" style="color: rgb(186, 45, 162);">public</span> <span class="" style="color: rgb(186, 45, 162);">func</span> myMethod() {</div><div style="margin: 0px; line-height: normal; color: rgb(209, 47, 27);" class=""><span class="" style="color: rgb(0, 0, 0);"> </span><span class="" style="color: rgb(62, 30, 129);">print</span><span class="" style="color: rgb(0, 0, 0);">(</span>"This is just a boring method"<span class="" style="color: rgb(0, 0, 0);">)</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class=""> }</div><div style="margin: 0px; line-height: normal; color: rgb(0, 0, 0);" class="">}</div><div class=""><br class=""></div></div></div></div></div></div></div><div class="">It has the downside of shifting code to the right (you could as well leave those extension-blocks unindented), but lots of advantages:</div><div class="">- No change for private needed</div><div class="">- It can be nested as much as you like to satisfy even the most absurd desires of encapsulation</div><div class="">- It reminds me on operator definitions inside type declarations </div><div class="">- No change for fileprivate needed (but actually, I think there is very little need to keep fileprivate)</div></div></body></html>