[swift-evolution] Final by default for classes and methods

Tino Heth 2th at gmx.de
Mon Dec 21 10:56:00 CST 2015


oh, cool - discussion ;-)

> However, any Swift application is necessarily going to have a lot of classes as the Cocoa frameworks require apps to subclass framework classes in many instances.  Even when we are not required to subclass a framework class they often require our types to be a class, for example when we are providing a delegate to a Cocoa class.  These requirements of the frameworks result in a lot of classes in Swift applications that are not ever intended to be subclassed.
So you'd vote for making non-final the default again as soon as the "Cocoa-legacy" is gone?

> You ask why I don’t think `inheritable` should be the default.  I believe I have addressed that by making a case that it is less clear and less safe as a default.
Sorry if he overlooked something, but I thought the arguments were against the current default…
What exactly compromises safety when a subclass is allowed to monitor usage of its inherited methods?
True, when a method is overwritten, the base class might lose something it relies on; but when this can't happen, can you point out an example where this behavior causes danger (damn, I actually know one, but you have to tell first ;-).

Tino
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151221/9fd809c6/attachment.html>


More information about the swift-evolution mailing list