[swift-evolution] [Proposal] Protected Access Level

Charles Srstka cocoadev at charlessoft.com
Mon May 30 14:59:21 CDT 2016

> On May 30, 2016, at 2:02 PM, Tino Heth <2th at gmx.de> wrote:
>> The purpose of access control isn’t really to keep out malicious users, though, it’s to prevent accidental misuse and clarify the interface.
> mh, I would call this a "documenting intend" ;-)

If you get the method as an autocomplete, you won’t see the documentation telling you not to use it.

>> One nice vector for accidental misuse is autocomplete. Even if layoutSubviews() has a great big // DON’T USE!!! in the documentation, it’s possible that someone is trying to remember the name of the API they need to use to tell the OS something needs to update its layout, so they type “layout” into the code editor, and lo and behold! Here’s something called layoutSubviews() that sounds like the sort of thing we want. And so it goes. A protected modifier in the language would prevent things like this.
> true — but even subclasses shouldn't call layoutSubviews unregulated, so I think this is a flawed example for the usefulness of protected.

This is why I prefer fileprivate(call) over protected.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160530/4e31684a/attachment.html>

More information about the swift-evolution mailing list