<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 Mar 21, 2017, at 10:02 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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="">On Tue, Mar 21, 2017 at 9:32 PM, Matthew Johnson<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class="gmail-"><blockquote type="cite" class=""><div class="">On Mar 21, 2017, at 9:17 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="gmail-m_-7525549124969564643Apple-interchange-newline"><div class=""><div dir="ltr" class="">On Tue, Mar 21, 2017 at 8:31 PM, Charles Srstka<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:cocoadev@charlessoft.com" target="_blank" class="">cocoadev@charlessoft.com</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Mar 21, 2017, at 8:15 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>> wrote:</div><br class="gmail-m_-7525549124969564643m_-8549773196041780473Apple-interchange-newline"><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; float: none; display: inline;" class="">On Tue, Mar 21, 2017 at 8:00 PM, Charles Srstka<span class="gmail-m_-7525549124969564643m_-8549773196041780473Apple-converted-space"> </span></span><span dir="ltr" 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;" class=""><<a href="mailto:cocoadev@charlessoft.com" target="_blank" class="">cocoadev@charlessoft.c<wbr class="">om</a>></span><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; float: none; display: inline;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473Apple-converted-space"> </span></span><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; float: none; display: inline;" class="">wrote:</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;" class=""><div class="gmail_extra" 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;"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><span class=""><blockquote type="cite" class="">On Mar 21, 2017, at 7:49 PM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>> wrote:<br class=""></blockquote></span><div class=""><span class=""><blockquote type="cite" class=""><br class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724Apple-interchange-newline"><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; float: none; display: inline;" class="">On Tue, Mar 21, 2017 at 6:46 PM, Charles Srstka<span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724Apple-converted-space"> </span></span><span dir="ltr" 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;" class=""><<a href="mailto:cocoadev@charlessoft.com" target="_blank" class="">cocoadev@charlessoft.c<wbr class="">om</a>></span><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; float: none; display: inline;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724Apple-converted-space"> </span></span><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; float: none; display: inline;" class="">wrote:</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;" class=""><div class="gmail_extra" 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;"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><span class=""><blockquote type="cite" class="">On Mar 21, 2017, at 5:26 PM, Xiaodi Wu via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:<br class=""></blockquote><div class=""><blockquote type="cite" class=""><br class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-interchange-newline"><div class=""><div 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;" class="">So, if four/five access modifiers are too many, which one is carrying the least weight? Which one could be removed to simplify the scheme while maintaining the most expressiveness? Which one doesn't fulfill even its own stated goals? Well, one of the key goals of `private` was to allow members to be encapsulated within an extension, hidden even from the type being extended (and vice versa for members defined in the type). It says so in the first sentence of SE-0025. As seen above in my discussion with Charles Srstka, even supporters of `private` disagree with that motivation to begin with. The kicker is, _it also doesn't work_. Try, for instance:</div><div 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;" class=""><br class=""></div><div 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;" class="">```</div><div 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;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>Foo {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> <span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">private</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>bar:<span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>{<span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">retur<wbr class="">n</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">42</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""></span><br class=""></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">extension</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>{</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo; color: rgb(186, 45, 162);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> <span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">private</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">var</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>bar:<span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>{<span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">retur<wbr class="">n</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(39, 42, 216);" class="">43</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="gmail-m_-7525549124969564643m_-8549773196041780473m_5268141798906625724m_1779768077800158996Apple-converted-space"> </span>}</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">}</span></div></div><div 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;" class="">```</div><div 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;" class=""><br class=""></div><div 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;" class="">The code above should compile and does not. If I understood correctly the explanation from a core team member on this list, it's unclear if it can be made to work without changing how mangling works, which I believe impacts ABI and is not trivial at all. Thus, (a) even proponents of new `private` disagree on one of two key goals stated for new `private`; (b) that goal was never accomplished, and making it work is not trivial; (c) no one even complained about it, suggesting that it was a low-yield goal in the first place.</div></div></blockquote></div><br class=""></span><div class="">Multiple people have already brought up cases in which they are using ‘private’. The repeated mention of another, unrelated use case that was mentioned in the SE-0025 proposal does not invalidate the real-world use cases which have been presented. In fact, it rather makes it appear as if the motivation to remove ‘private’ is based on a strange invocation of the appeal-to-authority fallacy, rather than an actual improvement to the language.</div></div></blockquote><div class=""><br class=""></div><div class="">I'm not sure how to respond to this. SE-0025, as designed, is not fully implemented. And as I said above, IIUC, it cannot be fully implemented without ripping out a lot of mangling code that is unlikely to be ripped out before Swift 4. _And there is no evidence that anyone cares about this flaw; in fact, you are saying as much, that you do not care at all!_ If this is not sufficient indication that the design of SE-0025 does not fit with the overall direction of Swift, what would be?</div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Because there are other uses cases for ‘private', *not* involving extensions, which I *do* care about. The fact that part of the proposal was badly written (and really, that’s all this is</div></div></div></blockquote><div class=""><br class=""></div><div class="">Huh? The code above *should compile*--that is a primary aim for SE-0025. It does not compile and there is not a timeline (afaict) for its compiling. It does not bother you that the 25th proposal considered in the Swift evolution process, already once revised, is not fully implemented and may never be?</div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">Someone finding a bug/oversight in the compiler behavior does not compel me to throw out the baby with the bathwater, no.</div></div></div></blockquote><div class=""><br class=""></div><div class="">You're not hearing the argument. No one "accidentally" included this design as part of SE-0025; it's sentence number one. And no one just "forgot" to make the code above work; it simply can't be accommodated by the current mangling scheme. And--what's more--_no one seems to be bothered by it_. If the first sentence of a proposal can't be implemented, and no one cares (!), is the proposal fundamentally flawed or is it just some bug?</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">The reason nobody cares much is because this is a degenerate case and is not actually how people want to use the feature. You don’t see people writing identically named fileprivate methods in extensions of a type in different files either. The purpose of the feature is not shadowing. That is a side effect. The purpose is to provide tight compiler-verified encapsulation.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Isn't supporting the following part and parcel of encapsulation?</div><div class=""><br class=""></div><div class="">```</div><div class=""><div class="">class Foo {</div><div class=""> private var a: Int { return 42 }</div><div class="">}</div><div class=""><br class=""></div><div class="">class Bar : Foo {</div><div class=""> private var a: Int { return 43 }</div><div class=""> var b: Int { return a }</div><div class="">}</div><div class=""><br class=""></div><div class="">print(Bar().b) // 43</div></div><div class="">```</div><div class=""><br class=""></div><div class="">Tight compiler-verified encapsulation would, AFAIK, require that the same thing work with types and extensions. As I said above in my reply to Drew, it's an inconsistent argument to say on the one hand that `private` is a powerful feature with many uses, and then when the general principles are applied in a logical manner to reveal certain use cases, to disown specific uses because they're hard to reason through or difficult to implement. We didn't want those anyway. Yes, yes we did.</div></div></div></div></div></blockquote><div><br class=""></div><div>Nobody is saying it shouldn’t work the way you state it should. Yes, it should work that way. Yes, it is a bug in the compiler. That does not mean this resembles the real world use cases we have for this feature. Pointing this out is not “disowning” these other uses.</div><div><br class=""></div><div>I don’t find these examples hard to reason through at all. It is quite clear what the correct behavior is. That doesn’t mean these are examples of good code. There are all kinds of ways to abuse most features in a programming language and this one is no exception.</div><div><br class=""></div><div>The encapsulation we’re looking for here is not encapsulation for the purpose of avoiding naming conflicts. Avoiding those is trivial at this level of granularity. The encapsulation we’re looking for, and have stated repeatedly, is compiler-verified encapsulation of invariants of one kind or another.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">Nothing more, nothing less.</div></div></div></blockquote><div class=""><br class=""></div><div class=""><br class=""></div><div class=""> </div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><span class="gmail-"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><span class=""><blockquote type="cite" class=""><div class=""><div class="gmail_extra" 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;"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">—it uses “class or extension” as a synonym for “any type declaration" when really, it makes just as much sense for structs to have private members as classes. Stuff happens!) does not invalidate the other use cases. And yes, I’m aware that my coding style may differ from other people, who may use the language in a different way. We shouldn’t break *their* use cases, either.</div></div></div></blockquote><div class=""><br class=""></div><div class="">We shouldn't break their use cases _without good reason_, but we shouldn't hesitate to break their use cases if (a) there is an extremely justifiable reason for it; and (b) the migration path is straightforward; and (preferably) also (c) the breakage is relatively uncommon. I happen to think those criteria are met for the reasons I've outlined extensively above, and you may certainly quibble with that conclusion</div></div></div></div></blockquote><br class=""></span></div><div class="">We’re simply going to have to disagree here.</div><span class="gmail-m_-7525549124969564643HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">Charles</div><div class=""><br class=""></div></font></span></div></blockquote></div><br class=""></div></div></span><span class="gmail-">______________________________<wbr class="">_________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/<wbr class="">mailman/listinfo/swift-<wbr class="">evolution</a></span></div></blockquote></div></div></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>