<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 20, 2017, at 9:33 PM, Greg Parker via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 20, 2017, at 4:54 PM, Douglas Gregor &lt;<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">Hello Swift community,</p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 16px; color: rgb(36, 41, 46); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; background-color: rgb(255, 255, 255);" class="">The review of SE-0159 "Fix Private Access Levels" begins now and runs through March 27, 2017. The proposal is available here:</p><blockquote style="box-sizing: border-box; margin: 0px 0px 16px; padding: 0px 1em; border-left-width: 0.25em; border-left-style: solid; border-left-color: rgb(223, 226, 229); background-color: rgb(255, 255, 255);" class=""><div style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px;" class=""><font color="#6a737d" face="-apple-system, BlinkMacSystemFont, Segoe UI, Helvetica, Arial, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol" size="3" class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md</a></font></div></blockquote></div></div></blockquote></div><div class="">-1. I yield the remainder of my time to Drew Crawford who satisfactorily explained my concerns.</div></div></div></blockquote><div><br class=""></div><div>I am also -1. &nbsp;</div><div><br class=""></div><div>I think there are two issues to be considered. &nbsp;One is scoped access itself and the other is the names of the access levels. &nbsp;</div><div><br class=""></div><div>I think a reasonable case can be made that changing the meaning of private and introducing fileprivate was a mistake. &nbsp;We probably should have left private alone and chosen a new name for scoped access. &nbsp;There was abundant bikeshedding over this at the time, but now we have the benefit of experience. &nbsp;I believe we should have simply called scoped access control `scoped`. &nbsp;It’s clear that some people would still oppose scoped access but I also don’t think we’d be revisiting this topic if we hadn’t changed the meaning of `private`. &nbsp;The passionate dislike of the feature seems to me mostly related to stealing the `private` keyword. &nbsp;</div><div><br class=""></div><div>I support correcting the naming mistake eventually. &nbsp;I’m neutral as to whether Swift 4 is the right time to do that. &nbsp;We just introduced a lot of churn in Swift 3. &nbsp;There is still inconsistency in Swift’s access control system as well as unmet needs (especially around submodules). &nbsp;It may be better to leave things alone for a release and make the change as part of a larger set of changes when access control and submodules are part of a release “theme”.</div><div><br class=""></div><div>I am extremely unconvinced that having a scoped access level is actively harmful. &nbsp;It introduces another choice in the language but no individual programmers or teams are forced to use the additional flexibility if they don’t want to. &nbsp;It would be very easy for linters to prohibit scoped access if there are teams that don’t want to use it. &nbsp;It is one extra degree of control for new programmers to learn but properly taught it helps programmers learn to think about encapsulation. &nbsp;This is a good thing.</div><div><br class=""></div><div>On the other hand, I believe removing scoped access <b style="font-style: italic;" class="">is </b>active harmful. &nbsp;It reduces our ability to properly encapsulate mutable state. &nbsp;For example, I like to use scoped access to create small state machine types which are used as part of the implementation of another type. &nbsp;These are usually structs with a private enum. &nbsp;The struct exposes methods which encapsulate state transitions. &nbsp;Without scoped access there is no way to encapsulate the state of the state machine and force all changes to go through one of the methods on the struct. &nbsp;This is just one example of how this feature can be very useful, there are many others. &nbsp;Small helper types like this are very idiomatic in Swift. &nbsp;It would be a big step backward to lose the ability to have proper encapsulation of small helper types.</div><div><br class=""></div><div>One common argument agains scoped access is that “you’re only protecting yourself from yourself”. &nbsp;I find this to be a bit of a straw man. &nbsp;It isn’t about “protection”. &nbsp;It is about compiler verified encapsulation. &nbsp;This prevents inadvertent changes that violate the intent of the design. &nbsp;For example, it is not out of the question that without scoped access a new member of a large team writes directly to the internal storage of the state machine in the above example. &nbsp;It is also possible that they do so in a way that represents an invalid state transition. &nbsp;The compiler would not catch this mistake. &nbsp;Hopefully it would be caught in a code review but I can imagine it getting missed for many different reasons. &nbsp;On the other hand, with scoped access the new team member would be unlikely to prefer changing access control to using the intended methods. &nbsp;If they did change access control this would be very likely to be caught in code review.</div><div><br class=""></div><div>Access control also provides compiler verified documentation of our code. &nbsp;This facilitates reasoning about our code. &nbsp;It also communicates design intent from the original author to future maintainers. &nbsp;Removing a tool that many people find useful in facilitating reasoning about code is actively harmful. &nbsp;Teams that don’t find this tool useful should use a linter and ban its use on their team. &nbsp;This approach would let those of us who do find this tool useful continue to use it.</div><div><br class=""></div><div>My observation thus far has been that people seem to be preferring private over fileprivate in many cases. &nbsp;I don’t think this preference is solely about typing four less characters. &nbsp;I think many people really do value the tighter encapsulation it provides.</div><div><br class=""></div><div>I do think changes to access control are necessary but I also think this proposal is not the right answer. &nbsp;The right answer should consider access control more holistically. &nbsp;Access control is not a theme for Swift 4. &nbsp;We shouldn't cause more churn around it until we’re ready to look at <i class="">all</i>&nbsp;of the issues with the current design. &nbsp;And we certainly should not make an actively harmful change to the language.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class=""><br class=""></div><div class="">--&nbsp;</div><div class="">Greg Parker &nbsp; &nbsp; <a href="mailto:gparker@apple.com" class="">gparker@apple.com</a> &nbsp; &nbsp; Runtime Wrangler</div><div class=""><br class=""></div><br class=""></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>