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

Nikita Leonov nikita.leonov at gmail.com
Tue Jul 5 19:14:23 CDT 2016


+1 with modifications. In my team we write “final class” a lot. We also do have a lot of internal frameworks and an ability to guide external frameworks uses is important for us. We have a lot of candidates in our frameworks that should be inheritable internally, but we do not recommend to extend them outside of framework.

My biggest worry with this proposal is already highlighted in a section "Modifier spelling alternatives”. Proposal introduces a set of new keywords to express relatively similar concept as current `final` keyword. We currently have already an ability to limit inheritance by use `final`, but we can not define a scope. However we also have keywords to define an accessibility scope:
* public — accessible everywhere
* internal — accessible within a module
* private — accessible within a file

For example, by leveraging existing keywords we can write code like following:
final(internal) class Foo {
  final(private) func bar() {
  }
} 
So the class `Foo` is inheritable within a module, but method bar is overridable only within same file. 
There is also optional `final(public)` that literally means no limitations on inheritance that can be used to indicate that class or method is `final(public)` on purpose by design. We use the similar approach in our code base with `internal`, while it is default keyword for classes and functions we still write it to show that it is internal by design and no public / private keyword missing.

Also with suggestion above we can default `final` to `final(private)`to keep backwards compatibility. 

Best,
Nikita Leonov

> On Jul 5, 2016, at 4:11 PM, Chris Lattner <clattner at apple.com> 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-announce mailing list
> swift-evolution-announce at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution-announce



More information about the swift-evolution mailing list