<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 Mar 3, 2017, at 11:26 AM, BJ Homer &lt;<a href="mailto:bjhomer@gmail.com" class="">bjhomer@gmail.com</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="">I agree that “scope(set: file)” reads better. It does make it a little strange that “scope(set)" is also valid, though; it’s ambiguous whether it takes labeled or unlabeled arguments. Under this proposal, all of these are valid:<div class=""><div class=""><br class=""></div><div class="">scope var<span class="Apple-tab-span" style="white-space:pre">                        </span>== scope(get, lexical)</div><div class="">scope(set) var<span class="Apple-tab-span" style="white-space:pre">                        </span>== scope(set, lexical)</div><div class="">private(set) var<span class="Apple-tab-span" style="white-space:pre">                </span>== scope(set, file)</div><div class="">internal(set) var<span class="Apple-tab-span" style="white-space:pre">                </span>== scope(set, submodule)</div><div class="">public(set) var<span class="Apple-tab-span" style="white-space:pre">                        </span>== scope(set, everywhere)</div><div class=""><br class=""></div><div class="">For beginner users, the use of “scope” as both an access modifier and a capability modifier seems a bit confusing; we’re “complecting” access control and capability control. Perhaps we should avoid the concept of “default arguments” altogether by separating the “scope” access control keyword from the concept of capability control. What about something like this?</div><div class=""><br class=""></div><div class=""><div class="">scoped var<span class="Apple-tab-span" style="white-space: pre;">                        </span>== access(get: lexical)</div><div class="">scoped(set) var<span class="Apple-tab-span" style="white-space: pre;">                </span>== access(set: lexical)</div><div class="">private(set) var<span class="Apple-tab-span" style="white-space: pre;">                </span>== access(set: file)</div><div class="">internal(set) var<span class="Apple-tab-span" style="white-space: pre;">                </span>== access(set: submodule)</div><div class="">public(set) var<span class="Apple-tab-span" style="white-space: pre;">                        </span>== access(set: everywhere)</div></div><div class=""><br class=""></div><div class="">Under this proposal, “scoped” is just another alias, similar to “private", “internal", and “public”. It does not have a privileged position, and it’s written as an adjective just like the others. The downside here is that we’re introducing two new keywords instead of one, but it means that we don’t need to mentally insert any default arguments. (The name of “access” is a placeholder, subject to bikeshedding.)</div></div></div></div></blockquote><div><br class=""></div><div>I’m definitely going to change the proposal to use `scoped` and `access`. &nbsp;Expressing the capability using an argument label is an interesting approach. &nbsp;The problem is that it stretches the way the aliases are defined pretty far. &nbsp;You can’t take an argument and use it as an argument *label* in a function you call. &nbsp;It also requires the model to have one overload for each capability instead of a single generic function.</div><div><br class=""></div><div>One of the big ideas here is that access modifiers can be conceptualized as an expression of a generic type BoundedCapability that is specialized according to the context of the declaration it is applied to. &nbsp;I don’t think we’d ever want to go in this direction, but it is theoretically possible that this could become a real expression that is evaluated at compile-time.</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=""><div class=""><br class=""></div><div class="">-BJ</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 3, 2017, at 4:23 AM, Daniel Leping 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=""><div 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="">General impression is positive in case shortcuts (private, bulblic) still remain for the most common use cases.</div><div 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=""><br class=""><div class="gmail_quote"><div class="">On Thu, 2 Mar 2017 at 21:58 Matthew Johnson via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<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 class="gmail_msg" style="word-wrap: break-word;"><div class="gmail_msg">I’ve been continuing to think about how to provide clear and consistent semantics for access control in Swift.&nbsp; This draft represents what I think is the best way to accomplish that.&nbsp; It eliminates the current inconsistencies and establishes a principled basis for the features we have today as well as the enhancements we may need in the future.&nbsp; It does this with minimal breaking changes.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The draft is included below and can also be found here:&nbsp;<a href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md" class="gmail_msg" target="_blank">https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md</a>.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">I’m looking forward to everyone’s feedback.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Matthew</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><h1 class="gmail_msg" style="box-sizing: border-box; margin-right: 0px; margin-bottom: 16px; margin-left: 0px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255); margin-top: 0px !important;">A Consistent Foundation For Access Control: Scope-Bounded Capabilities</h1><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">Proposal:&nbsp;<a href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md" class="gmail_msg" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none;">SE-NNNN</a></li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Authors:&nbsp;<a href="https://github.com/anandabits" class="gmail_msg" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none;">Matthew Johnson</a></li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Review Manager: TBD</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Status:&nbsp;<span class="gmail_msg" style="box-sizing: border-box; font-weight: 600;">Awaiting review</span></li></ul><h2 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-introduction" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#introduction" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Introduction</h2><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">This proposal introduces a consistent foundation for all access control in Swift: scope-bounded capabilities. The existing access control features are generalized with a single mechanism that unifies their semantics. This unified mechanism eliminates the inessential complexity and inconsistency of the current system while expanding its utility.&nbsp;</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Swift-evolution thread:&nbsp;<a href="https://lists.swift.org/pipermail/swift-evolution/" class="gmail_msg" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none;">Discussion thread topic for that proposal</a></p><h2 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-motivation" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#motivation" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Motivation</h2><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The new access control features in Swift 3 have proven to be extremely controversial. The most common refrain is that we need a more simple system. In order to accomplish this we need to do more than tweak the system we already have. We need to revisit the foundation of the system itself.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-simple-made-easy" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#simple-made-easy" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Simple Made Easy</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Rich Hickey gave a fantastic talk called [Simple Made Easy])(<a href="https://www.infoq.com/presentations/Simple-Made-Easy" class="gmail_msg" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none;">https://www.infoq.com/presentations/Simple-Made-Easy</a>). In this talk Rich explores the etymology and relationship of the words "simple", "complex", and "easy". The meanings he explores are:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">Complex: entangled, intertwined, interleaved, braided together</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Simple: one strand, single focus, disentangled</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Easy: familiar, nearby, readily at hand</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The central point Rich makes in this talk is that when a design entangles two orthogonal concepts complexity is the result. He coins the term "complect" to refer to this kind of inessential complexity. This complexity can be removed by disentangling the concepts. Instead of "complecting" independent concerns we can&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">compose</em>&nbsp;them.&nbsp;</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The result is a simpler system. It is simpler because independent concepts can be considered and understood independently of each other.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The composition of independent concerns also results in a more flexible system. When orthogonal concepts are entangled it is more difficult to extend the system to meet future needs. One concept cannot be extended independently of the other. It is not possible to make independent decisions about what should be orthogonal aspects of the design.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Rich believes that the programming community is often too quick to reach for an immediately "easy" solution. Unfortunately, the "easy" solution often entangles concepts and are therefor actually complex. He suggests that we&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">first</em>design a simple (i.e. disentangled) solution and then layer ease of use and familiarity on top, thus the title "Simple Made Easy".</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-two-orthogonal-concepts" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#two-orthogonal-concepts" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Two orthogonal concepts</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The access control system in Swift 3 incorporates two orthogonal concepts: availability and capability. Availability is what immediately comes to mind when one thinks of access control: a symbol is either available or it is not. Capability is more nuanced. It refers to what you can&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">do</em>&nbsp;with that symbol.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Each declaration supports a&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability which is always available when the symbol itself is available. Many declarations also offer&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capabiities (such as the ability to inherit, override, set a property, etc). These additional capabilities may be&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">less available</em>&nbsp;than the symbol itself.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">In Swift, availability is always specified in terms of a scope. Swift does not currently have a consistent way to talk about capabilities. Thus far we have introduced new syntax every time we wish to distinguish the availabiltiy of an&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>capability from that of the symbol itself:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">open</code>&nbsp;vs&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;access modifiers classes and methods</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">Access modifier parameterization for setter availability:&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private(set)</code></li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">@closed</code>&nbsp;attribute which has been discussed as a way to specify non-resilient enums in Swift 4*</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">It is clear that we need to be able to talk about not just basic availability, but also&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">capabilities</em>. It would be very nice if we had&nbsp;<span class="gmail_msg" style="box-sizing: border-box; font-weight: 600;">one</span>&nbsp;consistent way to do this. This can be accomplished by composing the concepts of availability and capability into the notion of a&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">scope-bounded capability</em>.&nbsp;</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">*<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">@closed</code>&nbsp;would lie outside the access control system proper. It is included for the sake of completeness. It is also included to demonstrate how the language currently lacks a clear and obvious way to specify new capability bounds when they are arise.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-problems-with-swifts-access-control-system" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#problems-with-swifts-access-control-system" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Problems with Swift's access control system</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Swift's current access control system can has several problems.</p><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-inconsistency" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#inconsistency" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Inconsistency</h4><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">As noted above, the ways&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capabilities are bounded is inconsistent. The semantics of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;are also inconsistent.&nbsp;</p><h5 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-internal-default" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#internal-default" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Internal default</h5><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The Swift evolution community has adopted the principle that nothing should be available outside a module without an explicit declaration of intent by a library author. This is an excellent default which protects library authors against making an error of omission that would require a breaking change to correct. Unfortunately this principle has not been consistently applied.</p><h5 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-public" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#public" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code></h5><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">In&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">most</em>&nbsp;cases&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;only provides access to the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability a declaration offers. This is true by definition for declarations do not offer&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capabilities but it is&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">also</em>&nbsp;true for classes (with respect to inheritance) and class methods (with respect to overrides).&nbsp;</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">However, there are three cases where&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;currently provides access to&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capabilities:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public var</code>&nbsp;allows access to the setter</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public enum</code>&nbsp;allows exhaustive switch</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public protocol</code>&nbsp;allows new conformances to be introduced</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">It is not currently possible to declare resilient enums or closed protocols but both have received significant discussion. Further, resilient enums need to be supported before ABI stability is declared. A consistent access control system would treat these as independent capabilities that are not made available with a simple&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;declaration.</p><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-private-and-fileprivate" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#private-and-fileprivate" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;and&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: inherit; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">fileprivate</code></h4><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The most heavily debated aspect of the changes to the access control system in Swift 3 is without question the change in meaning of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;to be the current lexical scope and the renaming of the file-level scope to&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">fileprivate</code>. This change was made with the idea that a lexically scoped&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;would prove to be a good "soft default" for a less-than-module availability bound. While many users appreciate the semantics of a scope-based access modifier it has not proven to be a good "soft default" and therefore does not deserve the name&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>.</p><h5 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-extensions" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#extensions" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Extensions</h5><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">In languages without extensions lexically scoped availability is equivalent to type-based availability for members of a type. In such a language it could make a reasonable default. Swift is not such a language.&nbsp;</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Using several extensions on the same type within the same file is an extremely common Swift idiom. This idiom is not well supported by a "soft default" of scope-based availability. The tension between a pervasive idiom and the "soft default" leads to confusion about when scope-based a availability is appropriate, and often an overuse of the feature. It also leads to the need to use&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">fileprivate</code>&nbsp;much more frequently than is desirable for such an awkward keyword.</p><h5 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-types-and-members" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#types-and-members" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Types and members</h5><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">A "soft default" should not have subtle behavior that has the potential to confuse beginners. Most beginners would expect&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">Foo</code>&nbsp;and&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">bar</code>&nbsp;in the following example to have the same visibility. This was true in Swift 2 but it is not true in Swift 3.</p><div class="gmail_msg m_172434477076412605highlight-source-swift m_172434477076412605highlight" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">private</span> <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">struct</span> <span class="gmail_msg m_172434477076412605pl-en" style="box-sizing: border-box; color: rgb(121, 93, 163);">Foo</span> {
    <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">private</span> <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> bar <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span>
}</pre></div><h5 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 0.875em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-an-advanced-feature" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#an-advanced-feature" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>An advanced feature</h5><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Lexically scoped availability has important uses such as preserving invariants. All access to invariant-related state can be routed through basis methods which access the state carefully without violating invariants, even when that access happens in an extension in the same file. We should not abandon this tool but it should not be the "soft default". It is best reserved for specific use cases where the guarantee it offers is important to correctess of the software.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-essential-and-inessential-complexity" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#essential-and-inessential-complexity" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Essential and inessential complexity</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The inconsistencies noted above and a bad "soft default" of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;are all forms of&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">inessential</em>&nbsp;complexity. This makes Swift's access control system more difficult to understand and use than it needs to be and causes confusion.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">At the same time the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">essential</em>&nbsp;complexity of capabilities that are bounded independent of basic symbol availability is not explicitly acknowledged and embraced. This also makes the access control system more difficult to understand and use than it should be. Users are not taught to think in terms of independently bounded capabilities. This is a concept that&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">could</em>&nbsp;be learned once and applied generally if it was more visible in the language.</p><h2 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-proposed-solution" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#proposed-solution" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Proposed solution</h2><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The proposed solution is to establish a semantic foundation for access control that is&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">simple</em>&nbsp;in the sense of composing rather than interleaving independent concerns. The solution is made&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">easy</em>&nbsp;by defining familiar names in terms of this foundation while preserving the semantics Swift users expect them to have. It is&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">consistent</em>&nbsp;in its use of a single mechanism for bounding capabilities and its default of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">internal</code>&nbsp;for&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">all</em>&nbsp;capabilities.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-scope-bounded-capabilities" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#scope-bounded-capabilities" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Scope-bounded capabilities</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">All access control is defined in terms of a parameterized access modifier that allows the user to specify a capability and a scope that bounds that capability.</p><div class="gmail_msg m_172434477076412605highlight-source-swift m_172434477076412605highlight" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box;">//</span> The scope of the setter is the current file.</span>
<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">scope</span>(<span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span>, file) <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> foo <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span></pre></div><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class=""><br class="webkit-block-placeholder"></div></div></div></blockquote><div class="">Here I suggest a bit different API to make it very distinct on which capability gets which access. Instead of ',' use ':'</div><div class=""><br class=""></div><div class="">scope(set: file) vat foo = 42</div><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 class="gmail_msg" style="word-wrap: break-word;"><div class="gmail_msg"><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Each parameter has a default argument. The default argument for the capability is simply the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability the declaration provides. For a variable this is the getter, for a method it is the ability to call the method, for a type it is the ability to use the type and so on. The default argument for the scope is the current lexical scope.</p><div class="gmail_msg m_172434477076412605highlight-source-swift m_172434477076412605highlight" style="box-sizing: border-box; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><pre class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box;">//</span> The scope of the getter is the current lexical scope.</span>
<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box;">//</span> This is equivalent to `private var foo = 42` in Swift 3.</span>
<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span>scope <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> foo <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span>

<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box;">//</span> The scope of the getter is the current file.</span>
<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">scope</span>(file) <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> bar <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span>

<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"><span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box;">//</span> The scope of the setter is the current lexical scope.</span>
<span class="gmail_msg m_172434477076412605pl-c" style="box-sizing: border-box; color: rgb(150, 152, 150);"></span><span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">scope</span>(<span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">set</span>) <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">var</span> baz <span class="gmail_msg m_172434477076412605pl-k" style="box-sizing: border-box; color: rgb(167, 29, 93);">=</span> <span class="gmail_msg m_172434477076412605pl-c1" style="box-sizing: border-box; color: rgb(0, 134, 179);">42</span></pre></div><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The scope of the basic capability implicitly bounds additional capabilities: if basic use of a symbol is not available it is not possible to anything with that symbol. This is similar to the existing rule that a type implicitly bounds the availability of all symbols declared within its scope: a&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public</code>&nbsp;property of an&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">internal</code>&nbsp;type is not available outside the module because the type itself is not available.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-aliases" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#aliases" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Aliases</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">This modifier is simple (in the sense defined above), general and powerful. However it is also unfamiliar, often slightly verbose, and offers a very wide configuration space. Familiar aliases are provided as "soft defaults" which are recommended for common use cases.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">These aliases introduce no additional semantics. Once a user understand scopes, capabilities and how they compose to produce scope-bounded capabilities the user also has the ability to understand&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">all</em>&nbsp;aliases we introduce. Tools could even make the definition of the alias available to remind the user of its underlying meaning (similarly to they way Xcode allows a user to command-click to see a symbol definition).</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">These aliases are defined in terms of the parameterized&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">scope</code>&nbsp;modifier:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">private(capability) = scope(capability, file)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">internal(capability) = scope(capability, submodule)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">public(capability) = scope(capability, everywhere)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">open = scope(inherit, everywhere)&nbsp;</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">open = scope(override, everywhere)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">final = scope(inherit, nowhere)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">final = scope(override, nowhere)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">total = scope(switch, everywhere)</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;reverts to the Swift 2 semantics.&nbsp;&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">scope</code>&nbsp;with no parameters has semantics equivalent to that of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">private</code>&nbsp;in Swift 3.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">internal</code>&nbsp;is specified in terms of&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">submodule</code>&nbsp;and is equivalent to&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">module</code>&nbsp;scope until submodules are introduced. It is specified this way to indicate the intent of the author should submodules be added.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">total</code>&nbsp;is a placholder subject to bikeshedding.&nbsp;&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">total enum</code>&nbsp;provides semantics equivalent to&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public enum</code>.&nbsp;&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public enum</code>&nbsp;receives the semantics of resilient enums. If a suitable shorthand is not identified the slightly longer&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">public(switch) enum</code>&nbsp;can be used to specify an enum which supports exhaustive switch outside the module.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">open</code>,&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">final</code>&nbsp;and&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">closed</code>&nbsp;are overloaded based on the kind of declaration they are applied to.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-scopes" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#scopes" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Scopes</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The hierarchy of scopes is as follows:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">nowhere</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">lexical</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">TypeName</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">extension</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">file</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">submodule</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">SubmoduleName</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">module</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">everywhere</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The name of any ancestor type or submodule of a declaration, including the immediately containing type or submodule, form the set of valid user-defined scope references.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Including&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">nowhere</code>&nbsp;allows us to define&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">final</code>&nbsp;in terms of this system. It also allows us to model all properties and functions with the same set of capabilities: the setter of a read only property is automatically bounded to&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">nowhere</code>&nbsp;and the&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">override</code>&nbsp;capability of a function that is not a class method is automatically bounded to&nbsp;<code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">nowhere</code>.</p><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Allowing users to reference any ancestor scope introduces affords advanced users a degree of control that is not possible in the current access control system. If submodules are introduced into Swift this additional control will be especially useful as a means to facilitate bounded collaboration between peer submodules allowing them to communicate in ways not available to the rest of the module.</p><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-capabilities" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#capabilities" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Capabilities</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The capabilities available depend on the kind of declaration an access modifier is applied to. All declarations offer a&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>capability that is always available when the declaration itself is available. The basic capability is specified by default when the scope modifier or a parameterized alias is used without an explicit capability argument. Some declarations also offer&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capabilities which may have an independent bound applied to them.</p><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-properties-and-subscripts" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#properties-and-subscripts" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Properties and subscripts</h4><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">get</code>&nbsp;(the basic capability)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">set</code>&nbsp;(for readwrite properties only)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">override</code>&nbsp;(for class properties only)</li></ul><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-functions-and-initializers" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#functions-and-initializers" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Functions and initializers</h4><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">call</code>&nbsp;(the basic capability)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">override</code>&nbsp;(for class methods only)</li></ul><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-types" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#types" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Types</h4><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">use</code>&nbsp;(the basic capability)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">inherit</code>&nbsp;(for classes)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">switch</code>&nbsp;(for enums)</li></ul><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-protocols" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#protocols" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Protocols</h4><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">use</code>&nbsp;(the basic capability)</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">conform</code></li></ul><h4 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 16px; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-extensions-and-typealiases" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#extensions-and-typealiases" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Extensions and typealiases</h4><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;"><code class="gmail_msg" style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.600000381469727px; padding: 0.2em 0px; margin: 0px; background-color: rgba(27, 31, 35, 0.0470588); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">use</code>&nbsp;(the basic capability)</li></ul><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-scalable-in-the-future" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#scalable-in-the-future" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Scalable in the future</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">As the language grows the mechanism of scope-bounded capabilities can be extended in an obvious way to meet the needs of future declarations and capabilities. Users are only required to learn about the new declaration or capability that was introduced. Their existing knowledge of the scope-bounded capability access control system is immediately applicable.</p><h2 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; line-height: 1.25; padding-bottom: 0.3em; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(234, 236, 239); color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-detailed-design" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#detailed-design" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Detailed design</h2><h3 class="gmail_msg" style="box-sizing: border-box; margin-top: 24px; margin-bottom: 16px; font-size: 1.25em; line-height: 1.25; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; background-color: rgb(255, 255, 255);"><a id="m_172434477076412605user-content-rules" class="gmail_msg m_172434477076412605anchor" href="https://github.com/anandabits/swift-evolution/blob/scope-bounded-capabilities/proposals/NNNN-scope-bounded-capabilities.md#rules" target="_blank" style="box-sizing: border-box; background-color: transparent; color: rgb(3, 102, 214); text-decoration: none; float: left; padding-right: 4px; line-height: 1;"><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u><u class="gmail_msg"></u></a>Rules</h3><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">The rules which make up the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">essential</em>&nbsp;complexity in Swift's access control system are:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">The default scope for all capabilites a declaration offers is module-wide (or submodule-wide in the future).</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The scope of a capability may be modified by an explicit access modifier.</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The scope of an&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capability is implicitly bounded by the scope of the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability.</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The scope of an&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capability may not be explicitly specified as greater than that of the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability.</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">If no scope is explicitly provided for the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability and an&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">additional</em>&nbsp;capability is specified to be available outside the (sub)module the&nbsp;<em class="gmail_msg" style="box-sizing: border-box;">basic</em>&nbsp;capability is also given the same availability.</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The scope of a declaration (including all capabilities) may be bounded by the declaration of ancestor.</li><li class="gmail_msg" style="box-sizing: border-box; margin-top: 0.25em;">The scope of a declaration may not be greater than the scope of the capabilities necessary to use that declaration: if you can't see a parameter type you can't call the function.</li></ul><p class="gmail_msg" style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);">Most of these rules already exist in Swift's access control system. There is one change and one addition:</p><ul class="gmail_msg" style="box-sizing: border-box; padding-left: 2em; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);"><li class="gmail_msg" style="box-sizing: border-box;">The first rule changes</li></ul></div></div></blockquote></div></div><span 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; float: none; display: inline !important;" class="">_______________________________________________</span><br 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=""><span 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; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br 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=""><span 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; float: none; display: inline !important;" class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br 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=""><span 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; float: none; display: inline !important;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></body></html>