<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body><div>On Fri, Oct 14, 2016, at 02:54 PM, Nevin Brackett-Rozinsky via swift-evolution wrote:<br></div>
<blockquote type="cite"><div dir="ltr"><div><div>On Fri, Oct 14, 2016 at 11:51 AM, Daniel Duan&nbsp;<span dir="ltr">&lt;<a href="mailto:daniel@duan.org">daniel@duan.org</a>&gt;</span>&nbsp;wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><span></span><br></div>
<div><span></span><br></div>
<div><span>On Oct 13, 2016, at 9:03 PM, Nevin Brackett-Rozinsky &lt;<a href="mailto:nevin.brackettrozinsky@gmail.com">nevin.brackettrozinsky@gmail.<wbr>com</a>&gt; wrote:</span><br></div>
<blockquote type="cite"><div dir="ltr"><span>Daniel, I would be interested to hear what, exactly, are the benefits your project has realized from the new “private” compared to the old “private” (which is now called “fileprivate”).</span><br></div>
</blockquote><div><span></span><br></div>
<div>There's no amazing insight here. The benefit is more granular control. The more people work on a project, the more useful this becomes.<br></div>
<div><br></div>
</div>
</blockquote><div defang_data-gmailquote="yes"><div><br></div>
<div>More granular control *within a single file*. That is where I have a hard time imagining the benefits, and thus am asking for details.<br></div>
<div><br></div>
<div>If there are multiple types within a single file, it is usually because they need to share implementation details.<br></div>
</div>
</div>
</div>
</blockquote><div><br></div>
<div>Just because they need to share some implementation details doesn't mean they should share all of them. Or better yet, a private/fileprivate type in a file doesn't have to share any implementation details, it can define a proper API that it exposes to the rest of the file while keeping its implementation details private, just as it would if it were an internal or public type.</div>
<div><br></div>
<blockquote type="cite"><div dir="ltr"><div><div defang_data-gmailquote="yes"><div>The only things that I see which scope-based access (the new “private”) brings to the table are:<br></div>
<div>• Scope-private members from other parts of the file are unavailable (and thus don’t show in autocomplete).<br></div>
<div>• Different extensions of a type can have scope-private members with the same name as each other.<br></div>
<div><br></div>
<div>The former seems negligible, because you are working *within the same file*. The API that a type vends within its own file is hardly worth optimizing for.<br></div>
<div><br></div>
<div>And the latter I would say is an anti-feature. Using multiple different members with the same name in extensions just makes it harder to rearrange the implementation, because those scope-private members will collide if moved into the same extension.<br></div>
<div><br></div>
<div>So I *really* don’t see the benefits. Yes, I understand that there is now more granular control over access within a single file. I am asking for examples of how that additional granularity provides *benefits*.<br></div>
</div>
</div>
</div>
</blockquote><div><br></div>
<div>Just because you're within a single file doesn't mean you need to throw away the principles of API design. Sure, it's not nearly as important as something that's more widely-visible, but that's not the same thing as saying it's not important at all. Careful control of implementation details vs exposed API even within a single file is still useful, either because it's much easier to make the type public if desired, or because it makes any future refactoring much easier. And it also helps you to reason about the code as you're looking at it, because when you're looking at a private declaration, you only have to consider the immediate enclosing scope, as opposed to a fileprivate declaration where you have to consider the whole file.<br></div>
<div><br></div>
<div>-Kevin Ballard</div>
<div><br></div>
<blockquote type="cite"><div dir="ltr"><div><div defang_data-gmailquote="yes"><div>&nbsp;On Fri, Oct 14, 2016 at 11:51 AM, Daniel Duan&nbsp;<span dir="ltr">&lt;<a href="mailto:daniel@duan.org">daniel@duan.org</a>&gt;</span>&nbsp;wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><br></div>
<div>You might as well ask "why not make everything public" if private and fileprivate makes no difference to you.<br></div>
</div>
</blockquote><div><br></div>
<div>That is not a fair assertion at all. The API which a type vends to other files within its module, and to clients outside its module, are significant parts of a quality and maintainable design.<br></div>
<div><br></div>
<div>I do not think the API which a type vends *within its own file* warrants such lofty prioritization.<br></div>
<div><br></div>
<div>&nbsp;<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><span>On Fri, Oct 14, 2016 at 11:51 AM, Daniel Duan&nbsp;<span dir="ltr">&lt;<a href="mailto:daniel@duan.org">daniel@duan.org</a>&gt;</span>&nbsp;wrote:<br></span></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><span><span></span></span><br></div>
<div><span><span></span></span><br></div>
<div><span><span>On Oct 13, 2016, at 9:03 PM, Nevin Brackett-Rozinsky &lt;<a href="mailto:nevin.brackettrozinsky@gmail.com">nevin.brackettrozinsky@gmail.<wbr>com</a>&gt; wrote:</span></span><br></div>
<div><span><span></span></span><br></div>
</div>
</blockquote><blockquote type="cite"><div><div dir="ltr"><div><span>As I see it, two significant drawbacks of the new “private” are increased complexity in the access control model, and encumbrance of the old “private” with the unwieldy moniker “fileprivate”.</span><br></div>
</div>
</div>
</blockquote><div><span></span><br></div>
<div>The first drawback is a truism: every language addition of feature makes it more complex.<br></div>
</div>
</blockquote><div><br></div>
<div>You can’t just write off the complexity cost like that. The new scope-based “private” access level brings *substantial* complexity, to both the implementation and the mental programming model. It creates *unutterable* access levels, where a scope can see a member of another scope, but cannot create its own member with the same access level.<br></div>
<div><br></div>
<div><br></div>
<div><blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><span>On Fri, Oct 14, 2016 at 11:51 AM, Daniel Duan&nbsp;<span dir="ltr">&lt;<a href="mailto:daniel@duan.org">daniel@duan.org</a>&gt;</span>&nbsp;wrote:<br></span></div>
<div><span><span></span></span><br></div>
<div><span></span><br></div>
<div>So we need to measure the benefit with other costs, which brings us to your second "drawback". I'm having a hard time understanding it. Is it too hard to type? If so, as an Objective-C survivor I disagree. The experience of reading code is harder and therefore more important than that of authoring code. "fileprivate" was chosen over many other alternatives because it's obvious to the reader. A shorter but equally obvious name would have been nice. But "unwieldy" is not enough reason to justify such source-breaking change at the moment.<br></div>
</div>
</blockquote><div><br></div>
<div>Right, “unwieldy” is not enough to justify a source-breaking change. I entirely agree.<br></div>
<div><br></div>
<div>It is the *complexity* of the current model that would justify the source-breaking change, if it does not have real benefits which stand on their own and outweigh the costs.<br></div>
<div><br></div>
<div>What unwieldiness *does* justify is a non-breaking change, such as introducing “privy” (or something else) as a synonym for “fileprivate”, then eventually deprecating and removing the latter.<br></div>
<div><br></div>
<div style="text-align:center;">• • •<br></div>
<div><br></div>
<div>I will also note that the principal practical effect of SE-0025 was “Replace a small number of occurrences of ‘private’ with ‘fileprivate’.”<br></div>
<div><br></div>
<div>That is essentially all it did to source code. It brought a significant increase to the complexity of the access control model, in order to make a few member declarations lengthier and more awkward.<br></div>
<div><br></div>
<div>Maybe there are other benefits, but I have not seen them.<br></div>
<div><br></div>
<div style="text-align:center;">• • •<br></div>
<div><br></div>
<div>Let me reiterate my stance: if the new scope-based “private” has benefits which outweigh its complexity cost, then we should keep it. Otherwise we should get rid of scope-based access control and reinstate the old file-based “private”.<br></div>
</div>
<div><br></div>
<div>Furthermore, we should rename “fileprivate” to something shorter and less awkward, which will play nice with submodules. If “private” is off the table then I propose “privy”, though I welcome other suggestions.<br></div>
<div><br></div>
<div>&nbsp;Nevin<br></div>
<div><br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div><div><blockquote type="cite"><div><div dir="ltr"><div>If the new “private” has brought real benefits sufficient to outweigh its complexity cost then I think it should stay, and if not it should go. Thus I am curious to see what benefits it has in practice.<br></div>
<div><br></div>
</div>
</div>
</blockquote><blockquote type="cite"><div><div dir="ltr"><div style="text-align:center;">• • •<br></div>
<div><br></div>
<div>Regardless of whether the new “private” is pulling its weight, I believe we should find a shorter name for “fileprivate”.<br></div>
<div><br></div>
<div>And I think Xiaodi has the right idea: whensoever in the future we decide to introduce submodules, it would be best if they subsumed the file scope. In essence, a submodule would be the mechanism for parceling out code which currently must reside in a single file (because it relies on “fileprivate” which is the old “private”).<br></div>
<div><br></div>
<div>That way a submodule could comprise several interrelated pieces which need to share privy details, while preserving their natural separation into distinct files. So it makes sense that we should find a replacement for “fileprivate” which is copacetic to submodules.<br></div>
<div><br></div>
<div>Actually, now that I write it down, I wonder if perhaps “privy” might work as a keyword. It is short, it means “being party to shared secret knowledge”, and its spelling conveys a sense of “private-ish”.<br></div>
<div><br></div>
<div>The other ideas I’ve come up with have shortcomings, such as “local” which has a pre-existing incompatible meaning in programming (otherwise it would be great), or “folio” which is not an adjective (and also isn’t ideal for the single-file case).<br></div>
<div><br></div>
<div>But “privy” just might work.<br></div>
<div><br></div>
<div>Nevin<br></div>
<div><br></div>
</div>
<div><div><br></div>
<div defang_data-gmailquote="yes"><div>On Thu, Oct 13, 2016 at 10:44 PM, Daniel Duan via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt;</span> wrote:<br></div>
<blockquote style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204, 204, 204);padding-left:1ex;" defang_data-gmailquote="yes"><div><div>I question the practicality of "<span class="highlight" style="background-color:rgba(255, 255, 255, 0)">use private heavily simply because I don’t want the burden of mixing private and fileprivate". In our experience in converting a very mature Swift application, we had no choice but to use both because we&nbsp;</span><span class="highlight" style="background-color:rgba(255, 255, 255, 0)">wanted private as much as possible but that's too restrictive in some cases. The granularity private and fileprivate provide is definitey a welcome change.</span><br></div>
<div><div><br></div>
<div>Daniel Duan<br></div>
<div>Sent from my iPhone<br></div>
</div>
<div><div><div><div><br></div>
<div>On Oct 13, 2016, at 3:11 AM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
</div>
<blockquote type="cite"><div><div><br></div>
<div><blockquote type="cite"><div>On 13 Oct 2016, at 08:25, Jean-Daniel via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div><br></div>
<div><div style="word-wrap:break-word;"><div><br></div>
<div><blockquote type="cite"><div>Le 13 oct. 2016 à 07:52, Chris Lattner via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; a écrit :<br></div>
<div><br></div>
<div><div style="word-wrap:break-word;"><div>On Oct 12, 2016, at 9:56 PM, Russ Bishop via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></div>
<div><blockquote type="cite"><div><div style="word-wrap:break-word;"><div><blockquote style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;" type="cite"><div><div style="word-wrap:break-word;"><div><blockquote type="cite"><div><div style="font-family:helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;">I actually consider it very lucky that most of our changes so far have been fairly non-controversial. Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.<br></div>
</div>
</blockquote></div>
<div><br></div>
<div>Strong agreement here as well. This proposal has been litigated numerous times already, and the bar for source-breaking changes is much higher now. To effectively re-open the discussion would require a proposal that significant changes the model with a lot of evidence that such a new model is a drastic improvement over what we have now. “Back out SE-0025” is not a viable option now.<br></div>
<div><br></div>
<div><span style="white-space:pre-wrap;"></span>- Doug<br></div>
</div>
</div>
</blockquote></div>
<div><br></div>
<div>Not really. This proposal could be backed out without source-breaking changes by treating private as a synonym for fileprivate and we’d have Swift 2 behavior without breaking source. If the core team doesn’t want to consider that then we can just move on and live with it.&nbsp;<br></div>
</div>
</div>
</blockquote><div><br></div>
</div>
<div>Not speaking for the core team, just MHO:<br></div>
<div><br></div>
<div>I agree with Russ here, and with others who have said upthread that the “thing that has changed” is that we are starting to get usage experience with fileprivate vs private.&nbsp; I think we all understand the value of having fewer access control levels, and so if “private” isn’t conceptually pulling its weight, then it is reasonable to consider phasing it out.<br></div>
<div><br></div>
<div>That said, there is no specific rush to have this discussion, and I think it is reasonable to put a pretty high burden of proof on someone who wants to drive such a proposal.&nbsp; For example, if we had the discussion in the spring timeframe, we should have a pretty large body of Swift 3 code readily at hand (e.g. SwiftPM packages and other various github repos).<br></div>
<div><br></div>
<div>Given that, it should be easy enough to see how widely private is actually being used in practice.&nbsp; If it is very rare, then the argument to ditch it (make it a synonym for fileprivate, and eventually phasing out fileprivate) is strong.&nbsp; If lots of people are using private and only some are using fileprivate, then the discussion is quite different.<br></div>
<div><br></div>
<div>-Chris<br></div>
</div>
</div>
</blockquote><div><br></div>
</div>
<div>I don’t think monitoring the usage of private vs fileprivate is fair. By default, people will use private until they encounter visibility issues and discover they need to change to fileprivate. So private will probably being use far more than fileprivate.<br></div>
<div>Nonetheless it does not mean people chosen private because it effectively reduce the visibility to the class scope, but just because it is easier to discover and to type than fileprivate and fit in many cases.<br></div>
<div><br></div>
<div>I tend to write class will all ivars private by default (as it is a sensible default), and then, when I start to write extensions and other parts, I have to switch to fileprivate for a bunch of ivars. It create an inconsistent mess in my ivars declaration as it is difficult to know if an ivar is private because I has to be, or because I didn’t encounter a case that need it to be fileprivate instead.<br></div>
<div><br></div>
<div>Honestly, I don’t see any value in the introduction of fileprivate.<br></div>
<div><br></div>
<div><br></div>
</div>
<div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/swift-evolution</a><br></div>
</div>
</blockquote></div>
<div><br></div>
<div>I also agree that monitoring the usage of private vs fileprivate is not fair. I now use private heavily simply because I don’t want the burden of mixing private and fileprivate (and find the name of fileprivate slightly verbose/ugly). But that does not mean I would vote for keeping private. I would still vote for going back to Swift 2 behaviour. But I agree that we can wait until the summer to look at this again.<br></div>
</div>
</blockquote><blockquote type="cite"><div><div><span>______________________________<wbr>_________________</span><br></div>
<div><span>swift-evolution mailing list</span><br></div>
<div><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br></div>
<div><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailma<wbr>n/listinfo/swift-evolution</a></span><br></div>
</div>
</blockquote></div>
</div>
</div>
<div><br></div>
<div>______________________________<wbr>_________________<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/mailma<wbr>n/listinfo/swift-evolution</a><br></div>
<div> <br></div>
</blockquote></div>
</div>
</div>
</blockquote></div>
</div>
</div>
</blockquote><div><u>_______________________________________________</u><br></div>
</div>
</div>
<div>swift-evolution mailing list<br></div>
</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><br></div>
</body>
</html>