[swift-evolution] Final by default for classes and methods
Stephen Celis
stephen.celis at gmail.com
Mon Dec 7 13:28:08 CST 2015
On Mon, Dec 7, 2015 at 2:21 PM, Kevin Lundberg via swift-evolution <
swift-evolution at swift.org> wrote:
> I can appreciate the desire for this, but I would not support it
> personally. In a former life developing C# code where this is the default
> behavior, I wanted to extend a class's behavior to make it work slightly
> differently, but since everything is final by default (sealed in C#
> parlance) I was prevented from doing so. The scope of my change was minimal
> and well defined, and it would not have negatively impacted the extending
> class's normal behavior. The code I was extending was open source so i
> ended up having to copy and paste the class and its dependencies into my
> project to do what I wanted. If I couldn't have done that then I'm not sure
> what the right approach would have been.
>
> In short, it is not always possible to know ahead of time how your clients
> will want to extend your API's functionality; artificially limiting this in
> my opinion will make it much harder to reuse components in previously
> unforeseen ways.
>
Was subclassing always necessary for extending this functionality? Could
you accomplish the same using extensions?
Stephen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151207/7723e9ec/attachment.html>
More information about the swift-evolution
mailing list