[swift-evolution] access control proposal

Matthew Johnson matthew at anandabits.com
Mon Dec 14 12:10:36 CST 2015

> On Dec 14, 2015, at 11:58 AM, Marc Knaup <marc at knaup.koeln> wrote:
> To sum up (what I understand) the new access modifier
> can be used only on type members (properties, methods, initializers, subscripts and nested types) - so not at file-level
> grants access to that symbol to
> the containing type
> (nested types)?
> extension in the same file
> and does not grant access to
> extensions declared in a different file
> subclasses
> other locations in the same file as the ones granted above
> Did I forget anything?

This is *not* correct.  It only grants access to other members declared within the same body.  Some examples may help clarify the concept:

struct S {
    // visible within the struct declaration only and *nowhere* else
    scoped let foo: String

    struct T {
        // still within the scope of S so foo is still visible here
        // buzz is only visible within the inner type, buzz is not visible to members of S
        scoped let buzz: String

// in same file
extension S {
    // foo is not visible here
    // bar is visible only within the extension in which it is declared and *nowhere* else
    scoped fun bar() -> String

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/65e72a44/attachment.html>

More information about the swift-evolution mailing list