[swift-evolution] [Review] SE-0159: Fix Private Access Levels
mattxg at gmail.com
Thu Mar 23 01:22:32 CDT 2017
> What is your evaluation of the proposal?
I disagree with this proposal. It removes functionality that I actively use.
This proposal aims to revert SE-0025 without really addressing the aims of that proposal, merely dismissing the result as "actively harmful" without defining what that means. SE-0159 raises the complaint that "private" is syntactically more natural default while "fileprivate" is a more useful default. On this point, I agree but the proposal is not about mere renaming.
The other discussion in the proposal is to ask the questions:
1. is that distinction between private and fileprivate actively used by the larger community of Swift developers
2. if it were used pervasively, would it be worth the cognitive load and complexity of keeping two very similar access levels in the language?
Fair questions but despite the proposal claiming "This proposal argues that answer to both questions is no", the proposal offers no *arguments* for the answers, it merely states a position.
For this reason, I feel the proposal is unreasonably dismissive of the aims of SE-0025.
Frankly, both these questions have subjective answers based on how programmers tend to design their programs. I personally like to build functionality using lots of very tiny types (many just 4 or 5 lines long), therefore, I frequently put multiple types in the same file (they're part of the same functionality, even if they're not part of the same type). However, I want to have actual interfaces and implementation hiding between them otherwise there's always the possibility of accidentally abusing the interface to each type. An access modifier narrower than the file, like the current scoped "private", is the *only* way to achieve this.
Reverting SE-0025 means the only way to have enforced interfaces between types is to place them in separate files. This is counterproductive for tiny types that form a single conceptual entity. Separate files also requires whole-program optimization for optimal performance.
The only conclusion I can make is that programmers in favor of this proposal simply don't program this way. However, I find it insulting that this proposal is essentially saying: your way of designing and structuring programs is wrong; you must use big monolithic types in their own files and endure reduced compilation (whole-program optimization) or runtime performance (no inlining between files with whole-program off).
I can't help but feel that this proposal is really misdirected frustration. Programmers who don't use clusters of tiny types in a single file shouldn't care about the existence of a scoped access modifier because it shouldn't affect them – they should use file access modifiers and be done. Yet apparently, it is file access modifier advocates pushing this proposal.
It really seems like the existence of a scoped access modifier is taking the blame for people's frustration that the simpler keyword ("private") is a less good default than the clunky keyword ("fileprivate"). I personally agree that the behavior or "fileprivate" is probably a better default so I understand the desire to give "private" back that meaning again. However, I don't want to lose a scoped access modifier because it is *useful* (for reasons of both project structure and compilation or runtime performance).
So... thumbs down from me. However, if someone wants to rename fileprivate -> private and rename private -> scope (or something) I'd be more supportive.
More information about the swift-evolution