<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 Jun 29, 2016, at 5:59 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</a>&gt; 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=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 29, 2016 at 5:55 PM, Matthew Johnson<span class="Apple-converted-space">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span><span class="Apple-converted-space">&nbsp;</span>wrote:<br class=""><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=""><br class=""><div class=""><div class=""><div class="h5"><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 5:41 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: 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"><div class="gmail_quote">On Wed, Jun 29, 2016 at 5:36 PM, Matthew Johnson<span class="">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span><span class="">&nbsp;</span>wrote:<br class=""><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=""><br class=""><div class=""><div class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 4:57 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 29, 2016 at 4:46 PM, Matthew Johnson<span class="">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span><span class="">&nbsp;</span>wrote:<br class=""><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=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 4:19 PM, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 29, 2016 at 4:16 PM, Matthew Johnson<span class="">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:matthew@anandabits.com" target="_blank" class="">matthew@anandabits.com</a>&gt;</span><span class="">&nbsp;</span>wrote:<br class=""><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=""><br class=""><div class=""><span class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 4:12 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: 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"><div class="gmail_quote">On Wed, Jun 29, 2016 at 4:07 PM, Jordan Rose<span class="">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:jordan_rose@apple.com" target="_blank" class="">jordan_rose@apple.com</a>&gt;</span><span class="">&nbsp;</span>wrote:<br class=""><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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jun 29, 2016, at 14:03, Xiaodi Wu &lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank" class="">xiaodi.wu@gmail.com</a>&gt; wrote:</div><br class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Wed, Jun 29, 2016 at 3:15 PM, Jordan Rose via swift-evolution<span class="">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span>wrote:<br class=""><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;"><span class=""><br class=""><br class="">&gt; On Jun 29, 2016, at 13:13, Jose Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com" target="_blank" class="">cheyo@masters3d.com</a>&gt; wrote:<br class="">&gt;<br class="">&gt; I know this might be have been brought up before but<br class="">&gt;<br class="">&gt; why not just disallow the “private" keyword for top level types, extensions etc.<br class="">&gt;<br class="">&gt; A fixit could change top level `private` to `fileprivate`.<br class="">&gt;<br class="">&gt; I think this is a little less confusing since effectively this is what is happening in the background.<br class=""><br class=""></span>That doesn’t fix anything for inner types, so it’s a lot less important than the rest of the amendment.<br class=""><br class="">There actually is an answer to this, which is that the core team expects 'private' to be the common keyword, and therefore it’s better if you can use it at the top level and ignore ‘fileprivate’ altogether in most programs.<br class=""></blockquote><div class=""><br class=""></div><div class="">On second thought, wouldn't all of this be inapplicable if `private` literally meant visibility *only* within the current declaration, and neither outside it nor inside any nested types, etc.?</div></div></div></div></div></blockquote><br class=""></div></span><div class="">Yes, but that's not very useful:</div><div class=""><br class=""></div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class="">public struct Foo {</div><div class="">&nbsp;<span class="">&nbsp;</span>private var value: Int = 0</div><div class="">&nbsp;<span class="">&nbsp;</span>public func test() {</div><div class="">&nbsp; &nbsp;<span class="">&nbsp;</span>print(value) // error</div><div class="">&nbsp;<span class="">&nbsp;</span>}</div><div class="">}</div></blockquote><div class=""><br class=""></div><div class="">I suppose you could say that nested<span class="">&nbsp;</span><i class="">types</i>&nbsp;are different from nested<span class="">&nbsp;</span><i class="">functions,</i>&nbsp;but then we start getting complexity in a different direction. And it still doesn't fix the default access within a private type.</div></div></blockquote><div class=""><br class=""></div><div class="">Let me offer a principled rule: if I write `private var foo`, then `foo` is invisible at such places within the declaration where writing `private var bar` at the same place would cause `bar` to be visible where `foo` is not or vice versa.</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">This violates the principle behind all of Swift’s access control rules.&nbsp; That principle is that access control is strictly based on a hierarchy of lexical scopes.&nbsp; This is a really great principle and is what makes Swift’s access control better than any other I know of (IMO of course).</div></div></div></blockquote><div class=""><br class=""></div><div class="">But however you slice it, some principle of Swift's access control rules is violated by `private`. If `foo` is visible in a place where I cannot write `private var bar` to mean the same visibility, then the access level of `foo` is unutterable in that location, which is unprecedented as well.</div></div></div></div></div></blockquote><div class=""><br class=""></div></span><div class="">I don’t think utterability was a conscious principle to the degree that scope based access control was.&nbsp; If that was the case the issue would surely have been identified during review.&nbsp; It wasn’t until Robert started the implementation that anyone (AFAIK) notices that the proposal introduces unutterable visibility in some cases.&nbsp; Utterability just isn’t something people were thinking about until then.</div><div class=""><br class=""></div><div class="">But you are right that unutterability is unprecedented and I think everyone agrees that it poses problems which is why Jordan and Robert have amended the proposal to make the visibility members of private types without explicit access control utterable.</div><div class=""><br class=""></div><div class="">The solution we want is to preserve *both* of these principles, not change which one were violating. :)</div></div></div></blockquote><div class=""><br class=""></div><div class="">If a private member must be visible within a nested type, then that access level necessarily becomes unutterable within the nested type unless we introduce another keyword, which is out of scope without a new proposal. There is no squaring the circle to be had. The amendment, to my understanding, simply hacks around this issue to make `private` nonetheless useful by allowing `fileprivate` things inside `private` things, but in so doing we're enshrining which of these principles we're violating, not finding a solution that avoids violating them.</div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">Do you mean a third principle which says something like “a member shall not have a higher access level than its parent”.&nbsp; If so, you are correct that Jordan’s amendment does violate that and another proposal would be necessary to give it a name that does not exist today.&nbsp; I don’ think that's going to happen for Swift 3.</div></div></div></blockquote><div class=""><br class=""></div><div class="">No, not exactly what I mean, but that is a concern. Jordan's proposal introduces a dichotomy between the actual access level (i.e. the answer to the question, which code can see this member?) and the access modifier which is used in conjunction with the member (which would become `fileprivate`). So yes, I can utter something, but it doesn't change the fact that the question "which code can actually see this member?" still has no utterable answer.</div></div></div></div></div></blockquote><div class=""><br class=""></div></div></div><div class="">The dichotomy is already implied by the semantics of SE-0025, it just left the visibility unutterable.&nbsp; Jordan’s amendment makes `fileprivate` have context / scope sensitive semantics which makes the answer utterable.</div></div></div></blockquote><div class=""><br class=""></div><div class="">Yes, I see your point now. It took me this long to understand what was being proposed because the name "fileprivate" explicitly disavows context-sensitive semantics. With this amendment, `fileprivate` will definitely need a renaming because it will neither be private nor scoped to file.</div></div></div></div></div></blockquote><div><br class=""></div><div>I think Jordan suggested it could be renamed after Swift 3 is out if we find a compellingly better name, it will just require a cycle of deprecation and then removal for `fileprivate`.</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-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><div class=""><div class="">The only way I can think of to make a scope-dependent visibility level *precisely* utterable everywhere within the relevant scope would be to introduce modifiers like `private(Foo)` where `Foo` is a parent scope.&nbsp; If you want it to be *precisely* utterable you could consider proposing something along these lines after Swift 3 is out.&nbsp; Any proposal along these lines would need to consider how to handle extensions since those don’t have names and would also need to handle degenerate cases such as `Foo` within `Foo` within `Foo`.</div><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: 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"><div class="gmail_quote"><div class="">&nbsp;</div><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=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">&nbsp;</div><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=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">&nbsp;</div><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=""><span class=""><br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: 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"><div class="gmail_quote"><div class="">&nbsp;</div><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=""><font color="#888888" class=""><div class=""></div><div class="">Jordan</div></font></span></div></blockquote></div><br class=""></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: 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 !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: 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 !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: 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:swift-evolution@swift.org" target="_blank" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: 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="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></span></div></div></blockquote></div></div></div></div></blockquote></span></div></div></blockquote></div></div></div></div></blockquote></span></div></div></blockquote></div></div></div></div></blockquote></span></div></div></blockquote></div></div></div></div></blockquote></div><br class=""></body></html>