[swift-evolution] [Proposal] Protected Access Level

Tino Heth 2th at gmx.de
Mon May 30 14:02:30 CDT 2016


> 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" ;-)

> 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160530/45de8cfe/attachment.html>


More information about the swift-evolution mailing list