[swift-evolution] [swift-evolution-announce] [Review] SE-0025 Scoped Access Level

Stephen Celis stephen.celis at gmail.com
Fri Feb 26 19:39:29 CST 2016


> What is your evaluation of the proposal?

I don't think it makes its case well. The alternatives it lists are sufficient and, if anything, mentioning them makes their case equally well (or better).

The suggestion that the current behavior "forces a one class per file structure" is misleading. While it may require a careful API designer to use one file to scope truly private behavior, they are free to implement other parts of this class/structure/enumeration (and others) elsewhere.

The one limitation of splitting logic over many files (a limitation the proposal does not mention) is that stored properties can only be defined in the initial definition of a class/structure. I can see a separate case (and proposal) to be made for allowing stored properties to be defined in extensions as long as the class/structure definition exists in the same module. I also remember reading a lukewarm discussion here around removing this limitation.

> Is the problem being addressed significant enough to warrant a change to Swift?

No. The problems it attempts to address can already be solved with the existing levels of access control. It also feels incongruous alongside them and would make Swift's design more confusing and complex.

I believe that for those that want it, this kind of scoping could be enforced using a linter.

> Does this proposal fit well with the feel and direction of Swift?

No. Swift has lately been removing, not adding, complexity. The bar for new language features is being set rather high, and this proposal in its current state is not convincing enough.

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

I don't know of any other languages that have 4 levels of access control. I have used languages that have more traditional "protected" and "private" inheritance-based access control (the latter of which is similar to that suggested in this proposal). I believe the Swift team carefully considered prior art and thoughtfully designed the current setup (as described in https://github.com/apple/swift/blob/master/docs/AccessControl.rst).

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

I read through the proposal and have thought extensively about the existing design.

--
Stephen



More information about the swift-evolution mailing list