<html><head><style>
body {
        font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
        padding:1em;
        margin:auto;
        background:#fefefe;
}

h1, h2, h3, h4, h5, h6 {
        font-weight: bold;
}

h1 {
        color: #000000;
        font-size: 28pt;
}

h2 {
        border-bottom: 1px solid #CCCCCC;
        color: #000000;
        font-size: 24px;
}

h3 {
        font-size: 18px;
}

h4 {
        font-size: 16px;
}

h5 {
        font-size: 14px;
}

h6 {
        color: #777777;
        background-color: inherit;
        font-size: 14px;
}

hr {
        height: 0.2em;
        border: 0;
        color: #CCCCCC;
        background-color: #CCCCCC;
    display: inherit;
}

p, blockquote, ul, ol, dl, li, table, pre {
        margin: 15px 0;
}

a, a:visited {
        color: #4183C4;
        background-color: inherit;
        text-decoration: none;
}

#message {
        border-radius: 6px;
        border: 1px solid #ccc;
        display:block;
        width:100%;
        height:60px;
        margin:6px 0px;
}

button, #ws {
        font-size: 12 pt;
        padding: 4px 6px;
        border-radius: 5px;
        border: 1px solid #bbb;
        background-color: #eee;
}

code, pre, #ws, #message {
        font-family: Monaco;
        font-size: 10pt;
        border-radius: 3px;
        background-color: #F8F8F8;
        color: inherit;
}

code {
        border: 1px solid #EAEAEA;
        margin: 0 2px;
        padding: 0 5px;
}

pre {
        border: 1px solid #CCCCCC;
        overflow: auto;
        padding: 4px 8px;
}

pre > code {
        border: 0;
        margin: 0;
        padding: 0;
}

#ws { background-color: #f8f8f8; }


.bloop_markdown table {
border-collapse: collapse;  
font-family: Helvetica, arial, freesans, clean, sans-serif;  
color: rgb(51, 51, 51);  
font-size: 15px; line-height: 25px;
padding: 0; }

.bloop_markdown table tr {
border-top: 1px solid #cccccc;
background-color: white;
margin: 0;
padding: 0; }
     
.bloop_markdown table tr:nth-child(2n) {
background-color: #f8f8f8; }

.bloop_markdown table tr th {
font-weight: bold;
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr td {
border: 1px solid #cccccc;
margin: 0;
padding: 6px 13px; }

.bloop_markdown table tr th :first-child, table tr td :first-child {
margin-top: 0; }

.bloop_markdown table tr th :last-child, table tr td :last-child {
margin-bottom: 0; }

.bloop_markdown blockquote{
  border-left: 4px solid #dddddd;
  padding: 0 15px;
  color: #777777; }
  blockquote > :first-child {
    margin-top: 0; }
  blockquote > :last-child {
    margin-bottom: 0; }

code, pre, #ws, #message {
    word-break: normal;
    word-wrap: normal;
}

hr {
    display: inherit;
}

.bloop_markdown :first-child {
    -webkit-margin-before: 0;
}

code, pre, #ws, #message {
    font-family: Menlo, Consolas, Liberation Mono, Courier, monospace;
}


.send { color:#77bb77; }
.server { color:#7799bb; }
.error { color:#AA0000; }</style></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="bloop_markdown"><p>How about this, it might make more sense and relax the behavior a little:</p>

<pre><code class="swift">// 1. file scope (Level 0)

// Level 0 because its declared at file scope
private struct A {
     
    /* implicit private */ init() {} // Level 1
}

// Level 0
struct B {
     
    // `A` is visible here and is seen as `fileprivate` because it is accessed
    // from a level &gt;= itself (imagine something like a "scope level tree").  
    // also every member of `A` are interpreted as  
    // `fileprivate` and everyting is visible again as intended  
    var a: A = A()
}

// 2. file scope (Level 0)

struct C {
     
    // `A` is not visible here
    // `B` is visible because its `internal` by default
}
</code></pre>

<p>Does this makes sense to you?</p>

<pre><code> ___________
| file Root |
|___________|
   |______________________
 __|_________________   __|_________________________
| struct B (Level 0) | | private struct A (Level 0) |
|____________________| |____________________________|
   |                      |  
 __|______________   _____|____________________
| var a (Level 1) | | private init() (Level 1) |
|_________________| |__________________________|

To check if `a` has visibility to `init` of `A` we need to compare the  
visibility level of `B` against `A`. If it is equal than `private` is  
handled as `fileprivate` which means that any other member from within  
the scope of `A` are also handled as `fileprivate`. We've get the same result
if `B`s level is greater than `A`s. That means that we'll get back the  
visibility by relaxing `private` in some cases as `fileprivate`.
</code></pre>

<p>The described behavior is the same for <code>private</code> on higher levels, but we don’t describe it as <code>fileprivate</code> there (or can we do that?):</p>

<pre><code class="swift">extension B {

   private func foo() {
     
        // `boo` should be visible here
    }
     
    private func boo() {
         
        // `foo` should be visible here
    }
}
</code></pre>

<p></p></div><div class="bloop_original_html"><style>body{font-family:Helvetica,Arial;font-size:13px}</style><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px; color: rgba(0,0,0,1.0); margin: 0px; line-height: auto;"><br></div> <br> <div id="bloop_sign_1466016831283463936" class="bloop_sign"><div style="font-family:helvetica,arial;font-size:13px">--&nbsp;<br>Adrian Zubarev<br>Sent with Airmail</div></div> <br><p class="airmail_on">Am 15. Juni 2016 um 20:53:21, Robert Widmann via swift-evolution (<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>) schrieb:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>Then it is no different from fileprivate.<br><br>~Robert Widmann<br><br>2016/06/15 11:47、Matthew Johnson &lt;matthew@anandabits.com&gt; のメッセージ:<br><br>&gt; <br>&gt;&gt; On Jun 15, 2016, at 1:37 PM, Robert Widmann &lt;devteam.codafi@gmail.com&gt; wrote:<br>&gt;&gt; <br>&gt;&gt; The scope of the *declaration* is not the issue.  The scope of its *members* is.<br>&gt; <br>&gt; Let’s consider an example:<br>&gt; <br>&gt; private struct Foo {<br>&gt;    var bar: Int<br>&gt; }<br>&gt; <br>&gt; // elsewhere in the same file:<br>&gt; var foo = Foo(bar: 42)<br>&gt; foo.bar = 44<br>&gt; <br>&gt; `Foo` is declared private.  Private for this declaration is at the file scope.  The `bar` member has no access modifier so it has the same visibility as the struct itself, which is file scope.  This will also be true of the implicitly synthesized memberwise initializer.  <br>&gt; <br>&gt; This means that it is possible to initialize `foo` with a newly constructed instance of `Foo` and to modify the `bar` member anywhere else in the same file.<br>&gt; <br>&gt; If `bar` was also declared `private` this would not be possible as its visibility would be restricted to the surrounding scope of the initial declaration of `Foo`.  This means `Foo` would need to provide an explicit initializer or factory method with `fileprivate` visibility in order to be usable.<br>&gt; <br>&gt; Members with no explicit access modifier should have the same *visibility* as their containing type (with a maximum implicit visibility of internal), not the same *modifier* as their containing type.  The only case where there is a distinction is the new `private` visibility.  Maybe that is what is causing the confusion?<br>&gt; <br>&gt; Does this help?<br>&gt; <br>&gt; -Matthew<br>&gt; <br>&gt;&gt; <br>&gt;&gt; ~Robert Widmann<br>&gt;&gt; <br>&gt;&gt; 2016/06/15 11:36、Matthew Johnson &lt;matthew@anandabits.com&gt; のメッセージ:<br>&gt;&gt; <br>&gt;&gt;&gt; The scope for a top-level declaration is the file itself.  This means that top-level declarations with `private` and `fileprivate` should have the same behavior.  They should not be uninstantiable or unusable.<br>&gt;&gt;&gt; <br>&gt;&gt;&gt; -Matthew<br>&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; On Jun 15, 2016, at 1:31 PM, Robert Widmann via swift-evolution &lt;swift-evolution@swift.org&gt; wrote:<br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; While implementing SE-0025 (fileprivate), I noticed an interesting bug in the proposal.  Under the implementation outlined there, any top-level structure, class, or enum declared private cannot possibly be instantiated and so cannot be used in any way.  Because of this, private top-level declarations are more often than not blown away entirely by the compiler for being unused.  It seems strange to me to allow a key language feature to act solely as a hint to the optimizer to reduce the size of your binary.  Perhaps the restrictions around private needs to be relaxed or the line between fileprivate and private needs to be investigated again by the community before inclusion in the language.<br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; Thoughts?<br>&gt;&gt;&gt;&gt; <br>&gt;&gt;&gt;&gt; ~Robert Widmann<br>&gt;&gt;&gt;&gt; _______________________________________________<br>&gt;&gt;&gt;&gt; swift-evolution mailing list<br>&gt;&gt;&gt;&gt; swift-evolution@swift.org<br>&gt;&gt;&gt;&gt; https://lists.swift.org/mailman/listinfo/swift-evolution<br>&gt; <br>_______________________________________________<br>swift-evolution mailing list<br>swift-evolution@swift.org<br>https://lists.swift.org/mailman/listinfo/swift-evolution<br></div></div></span></blockquote></div><div class="bloop_markdown"><p></p></div></body></html>