<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 >= 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">-- <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 <matthew@anandabits.com> のメッセージ:<br><br>> <br>>> On Jun 15, 2016, at 1:37 PM, Robert Widmann <devteam.codafi@gmail.com> wrote:<br>>> <br>>> The scope of the *declaration* is not the issue. The scope of its *members* is.<br>> <br>> Let’s consider an example:<br>> <br>> private struct Foo {<br>> var bar: Int<br>> }<br>> <br>> // elsewhere in the same file:<br>> var foo = Foo(bar: 42)<br>> foo.bar = 44<br>> <br>> `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>> <br>> 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>> <br>> 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>> <br>> 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>> <br>> Does this help?<br>> <br>> -Matthew<br>> <br>>> <br>>> ~Robert Widmann<br>>> <br>>> 2016/06/15 11:36、Matthew Johnson <matthew@anandabits.com> のメッセージ:<br>>> <br>>>> 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>>>> <br>>>> -Matthew<br>>>> <br>>>>> On Jun 15, 2016, at 1:31 PM, Robert Widmann via swift-evolution <swift-evolution@swift.org> wrote:<br>>>>> <br>>>>> 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>>>>> <br>>>>> Thoughts?<br>>>>> <br>>>>> ~Robert Widmann<br>>>>> _______________________________________________<br>>>>> swift-evolution mailing list<br>>>>> swift-evolution@swift.org<br>>>>> https://lists.swift.org/mailman/listinfo/swift-evolution<br>> <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>