[swift-evolution] Swift evolution proposal: introduce typeprivate access control level

Benjamin Spratling bspratling at mac.com
Fri Dec 2 08:07:27 CST 2016


I agree that there is a major problem with “subclasses must override these methods”.  We have no capability to describe this in Swift, and frankly, it feels like something that ought to be enforced.  It’s almost like we were really asked to conform to a protocol, but the protocol was a class.  Maybe this is an artifact from previous Obj-C development?  I.E. if it were designed in scratch in Swift it wouldn’t be a class with required overrides, but a protocol where every other method already had a default implementation?

> One of the simple examples would be: you need an API that requires overriding? Make it accessible for ancestors only (even in protocols). Despite the argument "ancestors can open it to public" (there are a lot of dangerous things to do) it makes the API much more clean and hides implementation complexity. Otherwise you just have to explain it in the doc "please don't call this method, it's an internal" which feels wrong.


More information about the swift-evolution mailing list