<div>Yeah I think the best course of action is to leave things alone until such time as we can more holistically work things as you outline.</div><div><br></div><div>Folks can strive to use private as the default lesser then module access level with fileprivate remaining available for those code patterns that require it for now (e.g. falling back on using the IMHO crutch of file co-residency).</div><div><br><div class="gmail_quote"><div>On Mon, Apr 3, 2017 at 1:28 PM Austin Zheng via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">I am a reluctant -1. If rejecting 159 was the right course of action to avoid unnecessary churn, I think that any further modification to the access control system should come as part of a comprehensive modules/namespaces/code organization proposal. Extracting a bit of progressive disclosure from yet another change in the rules really doesn’t seem worth the cost of developers having to relearn what access control does yet again.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Best,</div><div class="gmail_msg">Austin</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Apr 3, 2017, at 2:34 PM, Douglas Gregor via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:</div><br class="m_4349102097393679322Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg">Hello Swift Community,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">In rejecting <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md" class="gmail_msg" target="_blank">SE-0159</a>, the core team described a potential direction we would like to investigate for “private” access control that admits a limited form of type-based access control within files. The core team is seeking some discussion here and a motivated volunteer to put together a proposal along these lines for review in the Swift 4 time-frame (i.e., very soon). To be clear, the core team it’s sure this is the right direction to go… but it appears promising and we would *love* to be able to settle the access-control issue.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The design, specifically, is that a “private” member declared within a type “X” or an extension thereof would be accessible from:</div><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>* An extension of “X” in the same file</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>* The definition of “X”, if it occurs in the same file</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>* A nested type (or extension thereof) of one of the above that occurs in the same file</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">This design has a number of apparent benefits:</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>+ “private” becomes the right default for “less than whole module” visibility, and aligns well with Swift coding style that divides a type’s definition into a number of extensions.</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>+ “fileprivate” remains for existing use cases, but now it’s use it more rare, which has several advantages:</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">                </span>+ It fits well with the "progressive disclosure” philosophy behind Swift: you can use public/internal/private for a while before encountering and having to learn about “fileprivate” (note: we thought this was going to be true of <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md" class="gmail_msg" target="_blank">SE-0025</a>, but we were clearly wrong)</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">                </span>+ When “fileprivate” occurs, it means there’s some interesting coupling between different types in the same file. That makes fileprivate a useful alert to the reader rather than, potentially, something that we routinely use and overlook so that we can separate implementations into extensions.</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>+ “private” is more closely aligned with other programming languages that use type-based access control, which can help programmers just coming to Swift. When they reach for “private”, they’re likely to get something similar to what they expect—with a little Swift twist due to Swift’s heavy use of extensions.</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>+ Loosening the access restrictions on “private” is unlikely to break existing code.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">There are likely some drawbacks:</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>- Developers using patterns that depend on the existing lexically-scoped access control of “private” may find this new interpretation of “private” to be insufficiently strict</div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>- Swift’s access control would go from “entirely lexical” to “partly lexical and partly type-based”, which can be viewed as being more complicated</div><div class="gmail_msg"><br class="gmail_msg"></div></div><div class="gmail_msg">Thoughts? Volunteer?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_4349102097393679322Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>- Doug</div></div>_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div></div></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></div>