> On Dec 22, 2015, at 11:31 AM, Kevin Ballard via swift-evolution 
> <swift-evolution@swift.org> wrote:
> 
> UIKit classes aren't subclassable because of a lack of sealed-by-default, 
> they're subclassable because until very recently there was no way to mark 
> classes as not being subclassable.

There are two historical ways to disallow subclassing of public classes.
1. Perform an isa check in your -init method and halt if it's not your class. 
Attempts to subclass will get runtime errors.
2. Mark your class's metaclass symbol as un-exported. Attempts to subclass will 
get link-time errors.

Both are used but neither is common.


> Whether the language has final-by-default/sealed-by-default doesn't really 
> affect this in any way. I guarantee you that once Apple starts putting Swift 
> code in their frameworks, every single framework class Apple releases is 
> going to make an explicit decision about being final/sealed vs inheritable, 
> and the language defaults won't affect that one bit.

You may be overestimating Apple's engineers. We're just developers too. 
Whatever the default is, it will be incorrectly left in place more often than 
you'd like.


-- 
Greg Parker     gpar...@apple.com     Runtime Wrangler


_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to