<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 Jan 27, 2016, at 10:35 AM, David Owens II via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Sorry if I've missed it, but I didn't see these comments addressed in a way that I thought was sufficient.</div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Jan 25, 2016, at 3:47 PM, Dave Abrahams via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; float: none; display: inline !important;" class="">The place where I'm most concerned about this is in playgrounds. &nbsp;If</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; float: none; display: inline !important;" class="">we're going to use them to teach programming, it should be possible to</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: 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; float: none; display: inline !important;" class="">demonstrate encapsulation there.</span></div></blockquote></div><br class=""><div class="">Playgrounds support multiple files. Doesn't this alleviate this problem? Of course you can't model Swift's model in a single-file, but that's by-design.&nbsp;</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""></div></div><blockquote type="cite" class=""><div class=""><div class="">On Jan 27, 2016, at 7:44 AM, Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><span class="" style="float: none; display: inline !important;">Aside from that, as has been noted several times, the most common need is “current scope only”. &nbsp;It would be nice if that could actually be expressed in the language. &nbsp;There are often valid reasons to organize code such that more than one scope exists in the same file without a desire to share implementation details between the scopes. &nbsp;Right now there is a tension between code layout and the visibility semantics we actually desire and intend.</span></div></div></blockquote><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">I disagree. You can pattern your code so that this appears to be the "most common need", but you can also pattern identical functioning code so that this feature doesn't even work.</span></div><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">For instance, I know in my code, this really isn't the "most common need". In fact, in nearly all of my code, local would be completely useless because I put the majority of my APIs in extensions. I like to model the data on the type definition and the APIs in extensions.</span></div><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">This proposal would make using extensions as a means of grouping functionality impossible:</span></div><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">struct Foo {</font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">&nbsp; &nbsp; local count: Int = 0</font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">}</font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class=""><br class=""></font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">extension Foo {</font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">&nbsp; &nbsp; func hidden() { count += 1 } &nbsp;// error: count is not visible</font></span></div><div class=""><span class="" style="float: none; display: inline !important;"><font face="Menlo" class="">}</font></span></div></blockquote><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">So now we have to arbitrarily make `count` private, move `hidden()` into the `Foo` definition, or make `local` a whole lot more complicated.</span></div><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">If you design and write your code like you do in other languages, then ok, I can see a margin of usefulness from `local`.&nbsp;</span></div></div></div></blockquote><div><br class=""></div><div>Sure, if you use this method of organizing code `local` would be less useful and the need for file-level access would be much more common. &nbsp;I can see the benefits of organizing code this way; it is how code is organized in functional languages. &nbsp;When you follow this approach `local` would still be useful if you have helpers inside an extension. &nbsp;But you are right, it would not be the most common need.</div><div><br class=""></div><div>I haven’t seen much Swift code actually organized this way in the wild. &nbsp;Maybe that will change, maybe not. &nbsp;But I stand by the assertion that they way most people are writing Swift today leads to “current scope only” is the most common need in practice.</div><div><br class=""></div><div>Both `local` and `private` are useful. &nbsp;I would like to see both of them in the language.</div><div><br class=""></div><div>-Matthew</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><span class="" style="float: none; display: inline !important;"><br class=""></span></div><div class=""><span class="" style="float: none; display: inline !important;">-David</span></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>