[swift-evolution] [swift-evolution-announce] [Review] SE-0159: Fix Private Access Levels
michel.fortin at michelf.ca
Tue Mar 21 15:04:18 CDT 2017
> • What is your evaluation of the proposal?
Renaming `fileprivate` to `private` makes sense. In my code, I use `fileprivate` and `private` interchangeably, meaning that I write `private` for things that shouldn't be leaked to the whole module and if by chance the compiler complain I'll change it to `fileprivate` without a second thought. This tells me that I'm using the feature wrong: I should be writing `fileprivate` everywhere and narrowing it to `private` only where it is really important that I do so. But a name like `fileprivate` makes this rather difficult.
So I'd be glad to see that problem go away.
> • Is the problem being addressed significant enough to warrant a change to Swift?
I think it is significant enough. I think the core team's evaluation for Swift 3 that `fileprivate` would be rarely used was completely mistaken. Worse, forcing the use of the dirtier word `fileprivate` is draining all thoughtful intent from `private` in Swift 3. It's not a good thing when `private` is used only because it compiles and changed to `fileprivate` on a whim whenever the compiler complains.
While I don't have much attachment to the scoped-private concept, I'm not convinced its total removal is necessary either. Alternative 3 might solve this problem with less disruption to the language. While it offers some room to replicate the same problem I described above -- with different keywords -- I feel using a word like `scoped` would be less prone to overuse than `private` and therefore more truthful to the actual intent. If so, that would fix the problem too.
Either way, something must be done.
> • Does this proposal fit well with the feel and direction of Swift?
I think it does. The conflation of `private` and `fileprivate` at the top level of the file always sounded indicative to me of a flaw in the design. Correcting this would be an improvement.
> • If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
I'm used to D where `private` has the pretty much same meaning as `fileprivate` in Swift. I never found that much of a problem. But I've seen similar debates there too.
> • How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
I've read the proposal and most of the discussion, even though I haven't participated much.
More information about the swift-evolution