[swift-evolution] [Review] SE-0159: Fix Private Access Levels
ark dan
arkdan at icloud.com
Sat Mar 25 06:49:11 CDT 2017
• What is your evaluation of the proposal?
+1
• Is the problem being addressed significant enough to warrant a change to Swift?
Yes. For some strange reason, i can’t bring myself to write `fileprivate` instead of `private` by default - if i don’t specifically think of it, i end up with privates everywhere, and then have to go back and change to `fileprivate`. At times, it seems a bit annoying.
• Does this proposal fit well with the feel and direction of Swift?
Oh yes. fileprivate is too long a word for access level that i pretty much use as a default; and definitely not intuitive.
I write as much framework code, as application logic. Since Swift 3 i don’t remember many cases where i had to use `private`. I do, however, have many `private` members in my code - solely because `private` is way more intuitive to write.
~99% of privates in my code are there by mistake - but thats what i end up with. That means, there is no need for a mixed code like that 99% of the time:
private(set) var iosAudio: CMSampleBuffer?
private(set) var iosVideo: CMSampleBuffer?
fileprivate(set) var mic: CMSampleBuffer?
fileprivate(set) var serialNumber: String
fileprivate(set) var name: String
It also means, the 1% where i want to use `private`, the readers/users of my code may think it's a mistake too.
My point of view, the number of times i mean "this variable or function can only be accessed from within tis file" dwarfs the number when i mean "it can only be accessed by subclasses". They don't even compare.
If enough people need access based on class hierarchy, we should pick a keyword specifically for that - like "classprivate" if you will. But private within the file simply makes more sense.
• If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to
those?
N/A
• How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
I have strong opinion based on how i use Swift, which i love deep from the heart.
Thanks David & Doug for giving hope this may actually be reverted.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170325/aa320f5f/attachment.html>
More information about the swift-evolution
mailing list