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

Tino Heth 2th at gmx.de
Mon Dec 7 13:42:02 CST 2015


> When methods are overriden, design often requires that the super implementation be called, sometimes even at a specific time (before / after the new implementation). Should this change also provide support for this sort of pattern, or would that be beyond the scope? (Note that this was possible in Obj-C with NS_REQUIRES_SUPER)
Imho something like this would be way better than „willSet/didSet“, which introduces a bunch of new keywords and is only usable for properties.
Declaring everything final by default sounds good in theory, but I think in reality, it will just make things complicated in most cases — and beside more options for the compiler to optimize, I don’t see any benefit in forbidding a subclass to be notified when one of its inherited methods gets called.
So, I would vote for NS_REQUIRES_SUPER to be the default (because it doesn’t hurt in most cases, and it’s so hard to find a proper keyword for that behavior ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/c190df6f/attachment.html>


More information about the swift-evolution mailing list