[swift-evolution] Making protocol conformance inheritance controllable

Matthew Johnson matthew at anandabits.com
Fri Dec 11 07:52:42 CST 2015

> It is exacerbated by the fact that many Cocoa types which would naturally be value types or final classes in Swift are not designed this way due to their Objective-C heritage.
>> Foundation also exposes many non-final classes such as the immutable/mutable couples NSArray/NSMutableArray etc.

These are naturally value types in Swift and when designed that way don't exhibit the problem mentioned in this thread.

Also FWIW, it's not really safe to consider NSArray "immutable" because it is a reference type with a mutable subtype.  Specific instances of NSArray can be considered immutable when you know they are not actually instances of NSMutableArray and the interface to NSArray obviously does not allow mutation, but the assumption that NSArray is immutable has been the source of many bugs for many developers.  There is a reason it is not named NSImmutableArray.  The design of Cocoa could have been a lot more clear about this if it also had an NSImmutableArray class that also inherited from NSArray.  

More information about the swift-evolution mailing list