<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div style="font-family:Arial;">I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.<br></div>
<div style="font-family:Arial;"><br></div>
<div id="sig40804545"><div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif">Sincerely,</span><span class="font" style="font-family:arial, sans-serif, sans-serif"></span><br></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif"> Zachary Waldowski</span><span class="font" style="font-family:arial, sans-serif, sans-serif"></span><br></div>
<div class="signature"><span class="font" style="font-family:arial, sans-serif, sans-serif"> </span><a href="mailto:zach@waldowski.me"><span class="font" style="font-family:arial, sans-serif, sans-serif">zach@waldowski.me</span></a><br></div>
</div>
<div><br></div>
<div><br></div>
<div>On Fri, Oct 7, 2016, at 01:55 PM, Russ Bishop via swift-evolution wrote:<br></div>
<blockquote type="cite"><div><br></div>
<div><blockquote type="cite"><div>On Oct 7, 2016, at 9:13 AM, David Hart via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div>
<div style="font-family:Arial;"><br></div>
<div><div style="word-wrap:break-word;-webkit-line-break:after-white-space;"><div style="font-family:Arial;">I started the topic, but I also believe like you that the <b>fileprivate</b> vs <b>private(file)</b> discussion has already been thoroughly discussed and nothing new has been brought up. That’s not what I want to discuss.<br></div>
<div><br></div>
<div>I instead want to share my experience using <b>private</b> and <b>fileprivate</b> since release. Here are my thoughts:<br></div>
<div><br></div>
<div><ol><li>We should start with the premise that the proposal has added a substantial amount of complexity:<br></li><ol><li>It has added an extra modifier and access level to learn.<br></li><li>It has complicated the access level rules with Inner types as mentioned in the <b>Complications with private types</b> section of the proposal.<br></li><li>I have seen many people (twitter, work, slack) be confused about the difference between <b>private</b> and <b>fileprivate</b> at the global level. The answer is none, which shows that both modifiers are not very orthogonal.<br></li><li>Since release, I saw people prefer one over the other, as a matter of style. They tend to always use <b>fileprivate</b> or always using <b>private</b>. In the latter case, functions and properties get clumped in the same class scope instead of be written through multiple extensions.<br></li></ol><li>I have the impression that the motivations for the proposal are much less real in practice:<br></li><ol><li>The first motivation stated is: <i>"It is not clear whether the implementation details are meant to be completely hidden or can be shared with some related code without the danger of misusing the APIs marked as private.”</i> I’ve found that to be fairly rare in practice because the implementation details only used to leak inside the same file, which greatly reduces the dangers.<br></li><li>The second motivation stated is: <i>"It forces a one class per file structure, which is very limiting." </i>First of all, this is partly false. I think it forces putting classes which share implementation details in the same file, which I don’t think is necessarily a bad thing.<br></li></ol></ol><div><br></div>
</div>
<div>To summarise, it seems that the confusion the proposal brought over semantics and style are not worth the limited benefits that it brought. I’d be tempted to backtrack the proposal and re-introduce private as a file scoped access-level and deprecate fileprivate.<br></div>
<div><br></div>
<div>Thoughts?<br></div>
<div>David.<br></div>
<div><div><br></div>
</div>
</div>
</div>
</blockquote><div style="font-family:Arial;"><br></div>
</div>
<div><br></div>
<div>I agree. The minor benefit that fileprivate brings is not worth the cognitive overhead it introduces. We should just admit it was a mistake and back it out. We can avoid source-breaking changes by making fileprivate a synonym for private and provide fixits/warnings for a release to give people a chance to move off it.<br></div>
<div><br></div>
<div><br></div>
<div><br></div>
<div>Russ<br></div>
<div style="font-family:Arial;"><br></div>
<div><u>_______________________________________________</u><br></div>
<div>swift-evolution mailing list<br></div>
<div><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br></div>
<div><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div>
</blockquote><div style="font-family:Arial;"><br></div>
</body>
</html>