[swift-evolution] [Review] SE-0117: Default classes to be non-subclassable publicly

David Rönnqvist david.ronnqvist at gmail.com
Wed Jul 6 16:30:43 CDT 2016


>   * What is your evaluation of the proposal?

+1 (almost exclusively)

Writing good library code is hard and a lot of code isn't actually written to be externally subclasses (and trying to plan for subclassing can be difficult). Our team also writes "final class" in a lot of places and I don't like it (but wouldn't want final by default either).

This proposal feels like a sensible trade off to me. Having to intentionally mark classes for public subclassability leads to better safety (only classes being intended for external subclassing actually being subclassable), clarity (by documenting what's designed for subclassing/overriding), performance (by enabling optimizations if a class isn't subclasses internally) while still providing convenience within the module (enabling the authoring team to subclass and not having to put final throughout).

There is some negative with regards to limiting the ability to patch third party code, but I think the benefits of this proposal are worth that.

The behavior of Objective-C classes and @testablity are an important part of this proposal.

Bike sheding:

The subclassable/overridable pair read well on their own but it's not obvious to me that subclassable is also public and that it's not needed internally. This could be helped by requiring "subclassable" classes to also be marked "public" and making it an error to declare a class as "internal subclassable" or "private subclassable" (all 3 could have a simple fix-it).

I would also be fine with either "open" or "extensible" (although I could see "extensible" being interpreted as "can have extensions" instead of "can be subclasses").

>    * Is the problem being addressed significant enough to warrant a change to Swift?
>    * Does this proposal fit well with the feel and direction of Swift?

Yes. Being safe by default is well aligned with Swift. I would also argue that the same applies to being explicit about the authors intentions where it's needed. 

>    * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

None. Objective-C is completely open and I can't recall any other language that differentiates between "public" and "public subclassable".

>    * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?


Read the proposal and the review feedback so far.

- David

> On 6 Jul 2016, at 01:11, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hello Swift community,
> 
> The review of "SE-0117: Default classes to be non-subclassable publicly" begins now and runs through July 11. The proposal is available here:
> 
>    https://github.com/apple/swift-evolution/blob/master/proposals/0117-non-public-subclassable-by-default.md
> 
> Reviews are an important part of the Swift evolution process. All reviews should be sent to the swift-evolution mailing list at
> 
>    https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> or, if you would like to keep your feedback private, directly to the review manager.
> 
> What goes into a review?
> 
> The goal of the review process is to improve the proposal under review through constructive criticism and contribute to the direction of Swift. When writing your review, here are some questions you might want to answer in your review:
> 
>    * What is your evaluation of the proposal?
>    * Is the problem being addressed significant enough to warrant a change to Swift?
>    * Does this proposal fit well with the feel and direction of Swift?
>    * If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
>    * How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
> 
> More information about the Swift evolution process is available at
> 
>    https://github.com/apple/swift-evolution/blob/master/process.md
> 
> Thank you,
> 
> -Chris Lattner
> Review Manager
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution


More information about the swift-evolution mailing list