<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="">I am not suggesting to replace the meaning of private. I think that “file internal” or something similar would be a much more precise name for what is now called private in Swift. My suggestion is to add a scope based access level that would signal the author’s intent and make it enforceable by the compiler.<div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 24, 2016, at 3:44 AM, Thorsten Seitz &lt;<a href="mailto:tseitz42@icloud.com" class="">tseitz42@icloud.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="font-family: Avenir-Book; font-size: 13px; 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;"><span class="Apple-tab-span" style="white-space: pre;">        </span></div><div class="" style="font-family: Avenir-Book; font-size: 13px; 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;"><div class=""><blockquote type="cite" class=""><div class="">Am 23.01.2016 um 16:56 schrieb Ilya Belenkiy via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt;:</div><br class="Apple-interchange-newline"><div class=""><div class="">I hope that access control can be revisited. It is the number one complaint about Swift that I hear from experienced developers. The current solution came as a complete surprise to every ObjC developer I've talked to. The natural expectation was that a strong access control system would be part of a strong type system. I already submitted a pull request with a proposal for this after a lengthy discussion here, but so far it was ignored. I hope that this can be revisited. Even if most people who responded earlier in this list decided that they were happy with the current state, it represents a tiny fraction of people using the language, and at least all the people I talked to strongly disagree but just aren’t on the list.<br class=""><br class="">Right now access control is file based and not API based. This is much easier to implement but useless to express that certain elements of a class are implementation details that are not meant to be used anywhere else (someone can add more code to the same file and get access to the implementation details without modifying the class).<span class="Apple-converted-space">&nbsp;</span></div></div></blockquote><div class=""><br class=""></div><div class="">I think the file based approach for `private` has advantages because it allows putting several things that have to know each other deeply into the same file (C++ would use friend access for that).<div class=""><br class=""></div></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">It’s also impossible to hide APIs that are meant only for customization points of subclasses.<br class=""></div></div></blockquote><div class=""><br class=""></div><div class=""><div class="">Here I agree. What I am really missing is the ability to declare something „protected“ in a protocol (or class) which is not part of the public API but which I then can use in its default implementation but which has to be provided by implementors of the protocol.&nbsp;</div><div class=""><br class=""></div><div class="">Example (shortened and simplified to just show the relevant parts):</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">public protocol StandardGraphTraversal {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>// push() and pop() are implementation details and not part of the API</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func push(vertex: Vertex)</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func pop() -&gt; Vertex?</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>public func next() -&gt; Vertex?</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">public extension StandardGraphTraversal {</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>// leaving out things like visitor callbacks and coloring the visited vertices</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>public func next() -&gt; Vertex? {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>guard&nbsp;let source = pop() else {<span class="Apple-tab-span" style="white-space: pre;">                </span>// using pop() here</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                        </span>return nil</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>}</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>for target in graph.neighborsOf(source) {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                        </span>if shouldFollowVertex(target) {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                                </span>push(vertex)<span class="Apple-tab-span" style="white-space: pre;">                </span>// using push() here</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                        </span>}</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>}</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">// supplying the implementation detail: using a queue results in breadth first traversal</font></div><div class=""><font face="Menlo" class="">public struct BreadthFirstTraversal : StandardGraphTraversal {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>var queue: Queue&lt;Vertex&gt; = Queue()</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func push(vertex: Vertex) { return queue.push(vertex) }</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func pop() -&gt; Vertex? { return queue.pop() }</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">// supplying the implementation detail: using a stack results in depth first traversal</font></div><div class=""><font face="Menlo" class="">public struct DepthFirstTraversal : StandardGraphTraversal {</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>var stack: Stack&lt;Vertex&gt; = Stack()</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func push(vertex: Vertex) { return&nbsp;stack.push(vertex) }</font></div><div class=""><font face="Menlo" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>protected func pop() -&gt; Vertex? { return&nbsp;stack.pop() }</font></div><div class=""><font face="Menlo" class="">}</font></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span></div><div class=""><br class=""></div><div class="">Currently I cannot express that in Swift and have to make push() and pop() public :-(</div><div class=""><br class=""></div><div class="">(Allowing `internal` in public protocols would be sufficient in my example but would not help in more general cases where the implementors would have to be provided in another module by the framework user).</div><div class=""><br class=""></div></div><br class=""><blockquote type="cite" class=""><div class=""><div class="">.NET has a good solution that respects the OOP terminology and deals with accessibility in modules and at the API level:<br class=""><a href="https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx" class="">https://msdn.microsoft.com/en-us/library/wxh6fsc7.aspx</a></div></div></blockquote><div class=""><br class=""></div><div class="">`public` and `internal` seem to be quite the same as in Swift.</div><div class="">`private` is based on the type instead of the file. I think Swift’s file based `private` is better because it allows to express the same by putting a type into its file alone and allows to create strongly interdependent types by putting them together into the same file.</div><div class="">`protected` is what I’m missing as well</div><div class="">`protected internal` seems to be the union of `protected` and `internal`. I think that is not needed and is probably there to allow testing for which Swift has a nicer solution with @testable imports.</div><div class=""><br class=""></div><div class="">In short the only thing which is missing IMO is `protected`.</div><div class=""><br class=""></div><div class="">-Thorsten</div></div></div></div></blockquote></div><br class=""></div></body></html>