<div style="white-space:pre-wrap">Matthew, please take a look at my example with functions (it works today). In terms of scope, it should be the same with classes. I updated the proposal to restrict private to the immediate scope, so with the update, it will be Inner. Please take a look at the proposal. I tried to be very clear about both the meaning and motivation in the proposal example.</div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 28, 2016 at 8:58 AM Matthew Johnson &lt;<a href="mailto:matthew@anandabits.com">matthew@anandabits.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><div><br><br>Sent from my iPad</div><div><br>On Mar 28, 2016, at 6:48 AM, Ilya Belenkiy via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div style="white-space:pre-wrap">Outer</div></div></blockquote><div><br></div>Why Outer?  It looks to me like the enclosing lexical scope is Inner, thus innerVar would *not* be visible in Outer, it would only be visible in Inner.</div><div dir="auto"><br><blockquote type="cite"><div><br><div class="gmail_quote"><div dir="ltr">On Mon, Mar 28, 2016 at 7:30 AM Matthew Judge &lt;<a href="mailto:matthew.judge@gmail.com" target="_blank">matthew.judge@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 28, 2016 at 6:41 AM, Ilya Belenkiy <span dir="ltr">&lt;<a href="mailto:ilya.belenkiy@gmail.com" target="_blank">ilya.belenkiy@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr">lexical scope is the other way around: &quot;inner&quot; can see &quot;outer&quot;. For example:<div><br></div><div>func f() {</div><div>  let outer = 0</div><div> // f cannot use inner</div><div>   func g() {</div><div>       let inner = 1</div><div>       // g can use outer</div><div>   }</div><div>}</div><div><br></div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>Maybe I&#39;m off in my terminology, but I think my code example matches what you are saying here (outer is visible to g() but inner is not visible to f()</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div></div><div>It would work the same way for the access level. That said, I&#39;d rather not include this in the proposal. </div></div></blockquote><div><br></div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>So as the proposal stands now, what is the scope that innerVar is visible to in the following code: Inner or Outer?</div><div><br></div><div>class Outer {</div><div>    class Inner {</div><div>        private var innerVar: Int</div></div></div></div><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>    }</div><div>}</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="ltr"><div>The only change that the core team requested was the name changes. I personally would prefer a completely private version where you cannot inject a class into a scope to get access to the scope internals, but it&#39;s an edge case that could be argued either way, and I don&#39;t want to start another lengthy discussion. We already had quite a few.</div><div><div><div><br></div><div><div class="gmail_quote"><div dir="ltr">On Sun, Mar 27, 2016 at 11:17 PM Matthew Judge &lt;<a href="mailto:matthew.judge@gmail.com" target="_blank">matthew.judge@gmail.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div dir="auto"><div></div><div>I know it was suggested that it be the subject of a different thread, but it might be good to clarify how the new private is going to work (or at least what is currently envisioned).</div><div><br></div><div>My understanding is that the new private would be: </div><div>- visible only to the immediately enclosing scope</div><div>- including the scope of a inner nested scope</div><div>- not including the scope of an outer nested scope</div><div>- not visible to an extension </div><div><br></div><div>Said in code (all in the same file):</div><div>----------</div><div>class Outer { // Outer visible to module</div><div>    private var a: Int // visible to Outer, Inner1, &amp; Inner2</div><div><br></div><div>    class Inner1 { // Inner1 visible to module</div><div>        private var b: Int // visible to Inner1 only</div><div>    }</div><div>    private class Inner2 { // visible to Outer &amp; Inner(s)</div><div>        var c: Int // visible to Outer &amp; Inner(s)</div><div>    }</div><div>}</div><div><br></div><div>extension Outer { // visible to module</div><div>    // &#39;a&#39;, &#39;b&#39;, and &#39;Inner2&#39; NOT visible</div><div>}</div><div>----------</div><div>If this is the intended meaning of private, then fileprivate seems to be the same as private (private to the enclosing scope... which happens to be the file).</div><div><br></div><div>Something declared &quot;private&quot; at the top level of a file is fileprivate. There would still need to be a way to reference scopes other than the immediate one (especially since there is no way to say &quot;private&quot; and mean moduleprivate), though I think it would strengthen the argument for something along the lines of &quot;private(file)&quot;, since it would even further reduce the cases where you are spelling something more than just &quot;private&quot;</div></div><div dir="auto"><div><br></div><div><br>On Mar 27, 2016, at 17:31, Haravikk via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><br><div><div><blockquote type="cite"><div>On 27 Mar 2016, at 19:34, Jose Cheyo Jimenez via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><div><div dir="auto"><div><br></div><div>Public </div><div>External (default)</div><div>Internal</div><div>Private</div></div></div></blockquote><br></div><div>I still feel like these are still too vague; I’m not sure I like the use of external, as public to me is external since it exports outside of the module, whereas what you’re proposing is in fact just limited to the module itself. I dislike the current internal keyword too, but at least it reads as “internal to this module&quot;, this is why the more specific terms are better like:</div></div><div><br></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>public<span style="white-space:pre-wrap">                                </span>as-is, item is public/exported outside of module</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>private(module) or private<span style="white-space:pre-wrap">        </span>current internal, item is private to this module, would be the default</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>private(file)<span style="white-space:pre-wrap">                        </span>current private, item is private to this file</font></div><div><font face="Monaco"><span style="white-space:pre-wrap">        </span>private(scope)<span style="white-space:pre-wrap">                        </span>new visibility type, item is private to the current scope</font></div><div><br></div><div>Assuming I’m understanding the restriction properly this time =)</div><div><br></div><div>It’s also the easiest method if we do add another visibility later for sub-classes such as private(type), as it doesn’t even require a new keyword.</div></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><span>_______________________________________________</span></div></blockquote></div><div dir="auto"><blockquote type="cite"><div><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote></div></div></div></div></div>
</blockquote></div></div></div></blockquote></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></blockquote></div>