<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 class=""><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="-webkit-font-kerning: none;" class=""><font face="Avenir-Book" class="">Hi,</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class="">(wrote a bit or two about this before)</div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">For a moment, let's make the unlikely assumption that really no one has a problem </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">with changing the next Swift version, having lexical scope as the only scope mechanism. . . </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">which would be that each and every item is visible and accessible only inside the source level where it is declared,</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">unless of course revealed outwards with an access modifier. </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">(.e.g. protected, internal, public (private would be implicit)) </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Like it is in most other procedural/OOP languages.</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Now, also assume that Swift has always been that way: lexical scope only.</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Given this, as yet, hypothetical Swift environment, my questions are: </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Would this be feasible in Swift? </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">E.g. does it constrain/conflict with current Swift language constructs/organisation ? </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">(you can reveal items to the outside scope with access modifiers)</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Side effects, technical limitations?</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Am I right in thinking that Swift would be a lot easier to work with if lexical scope had</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">been there from the very beginning?</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">If Swift 4 would be set to lexical scope only, could the source conversion be automated successfully?</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class=""> E.g. by automatically adding the "internal" access modifier to all items that don't have an access modifier right now in Swift 3.x ? </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span><br class=""></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">If all this would be possible, it would of course be a very drastic change, </font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">but what is it worth to finally get scope access right once and for all ? (imho)</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class=""><br class=""></font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="-webkit-font-kerning: none;" class=""><font face="Avenir-Book" class=""><span style="-webkit-text-stroke-width: initial;" class="">The necessity of </span>“<span style="-webkit-text-stroke-width: initial;" class="">private</span>”<span style="-webkit-text-stroke-width: initial;" class=""> or </span>“<span style="-webkit-text-stroke-width: initial;" class="">fileprivate</span>”<span style="-webkit-text-stroke-width: initial;" class=""> keywords is by itself</span></font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="-webkit-font-kerning: none;" class=""><font face="Avenir-Book" class=""><span style="-webkit-text-stroke-width: initial;" class="">a clear signal that the current access mechanism is wrong, I think. </span></font></span></div><div style="margin: 0px; line-height: normal;" class=""><span style="-webkit-font-kerning: none;" class=""><font face="Avenir-Book" class=""><span style="-webkit-text-stroke-width: initial;" class=""><br class=""></span></font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">Very interested in your opinion, thank you.</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span style="font-family: Avenir-Book;" class="">Anyone?</span><font face="Avenir-Book" class=""><span style="font-kerning: none" class=""></span></font></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><span style="font-family: Avenir-Book;" class=""><br class=""></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0); min-height: 13px;" class=""><br class=""></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class="">TedvG</font></span></div><div style="margin: 0px; line-height: normal; -webkit-text-stroke-width: initial; -webkit-text-stroke-color: rgb(0, 0, 0);" class=""><span style="font-kerning: none" class=""><font face="Avenir-Book" class=""><a href="http://www.tedvg.com" class="">www.tedvg.com</a></font></span></div></div><div class=""><span style="font-kerning: none" class=""><br class=""></span></div><div class=""><br class=""></div><div class=""><br class=""></div><br class=""><blockquote type="cite" class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><span style="font-family: Avenir-Medium;" class=""><br class=""></span></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><span style="font-family: Avenir-Medium;" class="">Date: Wed, 12 Apr 2017 07:30:04 +0200</span></blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">From: David Hart <</span><a href="mailto:david@hartbit.com" style="font-family: Avenir-Medium;" class="">david@hartbit.com</a><span style="font-family: Avenir-Medium;" class="">></span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">To: Chris Lattner <</span><a href="mailto:clattner@nondot.org" style="font-family: Avenir-Medium;" class="">clattner@nondot.org</a><span style="font-family: Avenir-Medium;" class="">></span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">Cc: swift-evolution <</span><a href="mailto:swift-evolution@swift.org" style="font-family: Avenir-Medium;" class="">swift-evolution@swift.org</a><span style="font-family: Avenir-Medium;" class="">></span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">Subject: Re: [swift-evolution] Enhancing access levels without</span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span class="Apple-tab-span" style="font-family: Avenir-Medium; white-space: pre;">        </span><span style="font-family: Avenir-Medium;" class="">breaking</span><span class="Apple-tab-span" style="font-family: Avenir-Medium; white-space: pre;">        </span><span style="font-family: Avenir-Medium;" class="">changes</span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">Message-ID: <</span><a href="mailto:DACD7DE1-6BC6-457A-BE4D-B074C7B39A8C@hartbit.com" style="font-family: Avenir-Medium;" class="">DACD7DE1-6BC6-457A-BE4D-B074C7B39A8C@hartbit.com</a><span style="font-family: Avenir-Medium;" class="">></span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">Content-Type: text/plain;</span><span class="Apple-tab-span" style="font-family: Avenir-Medium; white-space: pre;">        </span><span style="font-family: Avenir-Medium;" class="">charset=utf-8</span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><font face="Avenir-Medium" class=""><br class=""></font><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><font face="Avenir-Medium" class=""><br class=""></font><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">On 12 Apr 2017, at 07:16, Chris Lattner <<a href="mailto:clattner@nondot.org" class="">clattner@nondot.org</a>> wrote:<br class=""><br class="">On Apr 11, 2017, at 3:53 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<blockquote type="cite" style="font-family: Avenir-Medium;" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">I understand what you are saying and I wouldn't be against relaxing that requirement (not talking for Chris here).</blockquote></blockquote></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class=""><blockquote type="cite" class=""><blockquote type="cite" class=""><br class=""></blockquote></blockquote></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class=""><blockquote type="cite" class=""><blockquote type="cite" class="">The model would change from "Types share scopes with their extensions in the same file the type was defined" to "Types and their extensions share the same scope in each file".</blockquote></blockquote></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class=""><blockquote type="cite" class=""><br class=""></blockquote></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class=""><blockquote type="cite" class="">Oh, I had missed that somehow. I agree that that is a very strange rule. Do you know why it was proposed that way?</blockquote></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class=""><br class=""></blockquote><blockquote type="cite" style="font-family: Avenir-Medium;" class="">We had to take a stance and Chris seemed to prefer the rule that was proposed. I didn't press because I'm sure he has reasons for preferring it that way. But I have a preference for generalizing visibility to all extensions, even to those in a different file than the type.</blockquote><br class="">To me, the reason for limiting it to a file is about predictability, the ability to locally reason about a type, and the need to define some boundary (for symbol visibility reasons). Saying that extensions to a type have access to private members if they are in the same module is just as arbitrary as limiting it to a single file, and a whole lot less useful from the “reasoning about a type” perspective.</blockquote><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><font face="Avenir-Medium" class=""><br class=""></font><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">I think you misunderstand. We were talking about two extensions of a type, in a different file from the type, to share private members between themselves.</span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""></blockquote><span style="font-family: Avenir-Medium;" class="">Doug Gregor mentioned it during the PR process and we added an example to disallow it, but in hindsight, I think it should be allowed.</span><br class=""><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class="">Expanding it beyond a module would require a ton of stuff to be exported that otherwise wouldn’t be, and would defeat a ton of optimization potential that we can’t accept.<br class=""><br class="">-Chris<br class=""><br class=""></blockquote><br style="font-family: Avenir-Medium;" class=""><br style="font-family: Avenir-Medium;" class=""></blockquote></body></html>