[swift-evolution] Final by default for classes and methods
2th at gmx.de
Tue Dec 22 03:32:57 CST 2015
> NS_REQUIRES_SUPER as the default is a bad idea. There's a big difference between methods where you SHOULD call super and methods where you MUST call super, and NS_REQUIRES_SUPER is meant for the latter case. The problem with using it where you simply SHOULD call super is there's occasionally a good reason to explicitly not call super, but there's no way to suppress the warning in that case (and no obvious syntax to propose for that).
Well, I'm no fan of spoon-feeding developers to protect them from themselves:
I would only insist on the call to super being there, not on it's actual execution.
> In addition, the cases where you MUST call super are really extremely rare.
Then one part of the original question has a clear answer: If it's ok to override and not call super, final is a bad default — if the original implementation is not important, final has only a little benefit in terms of performance for the price of restricting the user in a massive way.
More information about the swift-evolution