<div dir="ltr"><div style="white-space:pre-wrap">A very important property of the proposal is that anything declared &quot;scoped&quot; is completely sealed inside its scope and cannot be accessed from the outside. This means that the scope can be moved anywhere in the file without the danger of introducing access to implementation details. </div><div style="white-space:pre-wrap"><br></div><div style="white-space:pre-wrap">Allowing a containing scope to see &quot;scoped&quot; in its inner scope would mean that someone could just wrap a scope in another scope to gain access to implementation details without changing anything in the scope itself. The whole point of the proposal is to protect against something like this and make sure that implementation details remain hidden from anything outside the scope.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 4, 2016 at 4:37 PM Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">&gt; Currently there is no (good) way to limit extension methods to use only within the containing extension. I think the added clarity of a compiler-enforced access to “local” extension methods will be a solid win.<br>
<br>
I&#39;m seeing a lot of people say &quot;I want to keep things private to a particular extension within a file&quot;. I&#39;m still not convinced if that&#39;s a worthy goal, but if it&#39;s what people want, I&#39;d like to suggest an alternate semantic: `scoped` limits visibility to a particular top-level declaration block and all of the blocks nested inside it. That is, `local` declarations in a nested block are visible to the blocks it&#39;s inside, up to but not including the file scope.<br>
<br>
        class Foo {<br>
                struct Bar {<br>
                        var parentFoo: Foo<br>
                }<br>
                var myBar: Bar<br>
<br>
                // Here, neither of the implementationDetails is visible.<br>
        }<br>
<br>
        extension Foo {<br>
                func doSomething() {<br>
                        myBar.implementationDetail1()<br>
                }<br>
<br>
                extension Bar {<br>
                        scoped func implementationDetail1() {<br>
                                parentFoo.implementationDetail2()<br>
                        }<br>
                }<br>
<br>
                scoped func implementationDetail2() {<br>
                        print(&quot;All this compiles!&quot;)<br>
                }<br>
        }<br>
<br>
        extension Foo {<br>
                // Here, neither of the implementationDetails is visible.<br>
        }<br>
<br>
--<br>
Brent Royal-Gordon<br>
Architechies<br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div>