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

Matthew Johnson matthew at anandabits.com
Wed Dec 23 12:45:45 CST 2015

> On Dec 23, 2015, at 12:43 PM, Craig Cruden <ccruden at novafore.com> wrote:
> I thought sealed and final were effectively the same thing for production code, which is why it confuses me when you say final is right anything less including sealed is not.
> In Scala at least sealed is final with the exception that subclasses within the same source file are allowed.  When it is compiled and shipped - you can no longer modify that source file….. 

They are not at all the same.  The difference is that with sealed you cannot inherit from classes in other modules which are not explicitly marked `inheritable`, but you can inherit from classes in your own module that are not explicitly marked `inheritable`.  That is a big difference.

>> On 2015-12-24, at 1:36:01, Matthew Johnson via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> I strongly feel that I shouldn’t pay a price in production code in order to better support those use cases.  IMO ‘final’ is the right default for production code and we pay a price if the default is anything less, including ‘sealed’. 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151223/792529a7/attachment.html>

More information about the swift-evolution mailing list