Making protocol conformance inheritance controllable


(E. Maloney) #1

[...] I'd like to float the idea that protocol conformances *not be* inherited by default. If you declare a class as conforming to a protocol, only exactly that class can be bound to a type parameter constrained by that protocol [...]

You just blew my mind.

This is undoubtedly a complication of the language, but I think it might let us more accurately model a lot of things people seem to want to do in practice with class hierarchies and protocols, and it simplifies the behavior of the arguably common case where inheritance of the conformance isn't desired. What do you all think?

Anything that raises the possibility of avoiding "required init(coder: NSCoder) { fatalError() }" all over my UIKit subclasses gets my support.

It's a bit radical, but the benefits as you've described them outweigh the costs, IMO.

All the best,
E.

ยทยทยท

On Thu, 10 Dec 2015 18:04:02 -0800, Joe Groff <jgroff@apple.com <mailto:jgroff@apple.com>> wrote: