[swift-evolution] [Proposal] Protected Access Level

Tino Heth 2th at gmx.de
Mon May 30 11:23:04 CDT 2016

> Couldn’t you use the same reasoning to claim there shouldn’t be access control at all? Just add documention on methods you want to mark private telling users of the library not to call them!

I guess you are making fun, but actually, good old Objective-C messaging works just that way:
You can call all those dangerous and forbidden private methods easily...
Writing special comments is just one way to document APIs; having no (official) documentation at all is documentation as well ("don't use this!").

Most technical limitations can be cracked by skilled hackers (working around "protected" is especially easy), so I really think that (for example) declaring a method "final" says "I don't want this to be changed in a subclass" in the first place, and the compiler error that is triggered when you try to break the limitation is little more but a remainder.

Enforcing limitations using hacks causes confusion, so I would never use such tricks in production code.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160530/6b97da13/attachment.html>

More information about the swift-evolution mailing list