[Review] SE-0169: Improve Interaction Between private Declarations and Extensions

I, uh, wish to object to your implication that C++ 'friend' reflects actual design intent in most cases. :-)

Jordan

···

On Apr 7, 2017, at 04:18, Gwendal Roué via swift-evolution <swift-evolution@swift.org> wrote:

- the private/fileprivate qualifier used not to be a intrinsic property of an object (because one had to move from private to fileprivate as soon as an extension was added). Now private/fileprivate can be made meaningful, and above all *stable*. A scenario where private is turned into a fileprivate now involves something called "friendship" in C++: fileprivate now reflects *actual design intent*, not "shut up this stupid compiler".

-1 (strongish) on this proposal for the reason I comment earlier in the
discussion thread.

This weakens private for not an atypical use case of private that I
currently have. It muddies the water between fileprivate and private making
private more confusing and in away surprising. We have a clear and explicit
way in fileprivate to do what this proposal does by tweaking private. I get
that folks don't like fileprivate the word but I don't see that being a
strong enough reason to take things in this direction. It also builds on
file based access scoped which I believe is not the direction we should be
going in a modern language such as swift.

If changes are this strongly desired I believe we should bite the bullet
and rename "private" to "scope[d]" and "fileprivate" to "private". Then
work on making this renamed private work across files coupled either with a
submodule concept (likely tagging wholes file as existing in a module)
and/or making it work across extensions or class trees. ...or as suggested
by others leave "private" as is and just rename "fileprivate" to "shared"

.. or to "local", as "shared" is confusing if it is shared with all module. The meaning of "local" is also not 100% obvious, but:
* IMO it is not hard to tech public->internal->local->private
(internal for module, local for file/submodule, private for scope)
* Don't need to change anything in meaning of current access modifiers
* We even can keep 'fileprivate' as an alias(depricated?) for 'local', so we can have 100% source compatibility
* 'local' is very short and good looking keyword, that's important given it will be used often
* 'private' still be the most strict access level, soft default. Then you can promote to next level('local') if decide you need wider access scope.
* Yes, I remember, 'local' was rejected previously, but world is changing, currently many(most?) of us agree that 'fileprivate' more harmful than other not clear meaning but good looking word; that 'fileprivate' is still used very often and *will* be used often; and IIRC during the SE-0025 there was an intention to fix *later* awkward 'fileprivate' keyword, but now we was told "this is the last chance, nothing related to access modifiers will be in scope of any future Swift and renaming is not in scope of current stage also". So given this all, I think we can re-consider 'local' keyword.

Seems like such proposal also will have a huge support of the community.

Btw, when was *that* moment(which most of us missed, as I understand) we were *allowed* to discuss access modifier changes?

···

On 07.04.2017 16:56, Shawn Erickson via swift-evolution wrote:

or something like that so it can expand it capability as I outline a
sentence earlier.

This proposal doesn't help like I think a more comprehensive rework would,
it actually hurts my usage of current private.

On Thu, Apr 6, 2017 at 4:10 PM Douglas Gregor <dgregor@apple.com > <mailto:dgregor@apple.com>> wrote:

    Hello Swift community,

    The review of SE-0169 "Improve Interaction Between private Declarations
    and Extensions" begins now and runs through April 11, 2017. The
    proposal is available here:

        https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.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. When replying, please try to keep the proposal link at
    the top of the message:

        Proposal link:

            https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md

        Reply text

            Other replies

              ________
              <https://github.com/apple/swift-evolution/blob/master/process.md#what-goes-into-a-review-1&gt;What
              goes into a review?

    The goal of the review process is to improve the proposal under review
    through constructive criticism and, eventually, determine 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,

    -Doug

    Review Manager

    _______________________________________________
    swift-evolution-announce mailing list
    swift-evolution-announce@swift.org
    <mailto:swift-evolution-announce@swift.org>
    https://lists.swift.org/mailman/listinfo/swift-evolution-announce

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

If private is required to be tied to types forever and always, then yes, this proposal should be accepted. To do otherwise is to suggest that the use of "private" by beginners and the use of same-file extensions by beginners are incompatible. The former is silly; "private" is what beginners will naturally reach for. The latter is possible, but historically the use of same-file extensions has been quite idiomatic. So, I reluctantly agree we should accept this proposal.

-BJ

···

On Apr 7, 2017, at 10:34 PM, John McCall via swift-evolution <swift-evolution@swift.org> wrote:

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org> wrote:

What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

If private really is tied to scopes now and forever, I certainly have no doubt these change should be accepted to alleviate the biggest annoyance with it.

Should this be accepted, to me, using "fileprivate" serves as a flag that another type has privileged access to another type's private members. Unfortunately, because fileprivate is needed for extensions of the same type, then the keyword loses this meaning. If I choose to use extensions to define a type (as was a practice greatly encouraged in Swift 1/2), fileprivate serves no self-documentation role beyond "private".

Additionally, I truly believe this proposal would align the access control with what newcomers to the language are already familiar with. When they adopt the Swift practice of multiple extensions, they'll be confused why they have to change private to fileprivate, and may instead just decide to stick it all in one definition. Anecdotally, that's certainly what I expected when Swift 3 was released, and I've now stopped using extensions for types as much simply because of fileprivate.

···

On Apr 7, 2017, at 10:01 PM, BJ Homer via swift-evolution <swift-evolution@swift.org> wrote:

If private is required to be tied to types forever and always, then yes, this proposal should be accepted. To do otherwise is to suggest that the use of "private" by beginners and the use of same-file extensions by beginners are incompatible. The former is silly; "private" is what beginners will naturally reach for. The latter is possible, but historically the use of same-file extensions has been quite idiomatic. So, I reluctantly agree we should accept this proposal.

-BJ

On Apr 7, 2017, at 10:34 PM, John McCall via swift-evolution <swift-evolution@swift.org> wrote:

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org> wrote:

What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

> What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

···

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org> wrote:

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Fair enough - in this case, definitely +1 on the current proposal.

Kuba

···

On 8 April 2017 at 06:34, John McCall <rjmccall@apple.com> wrote:

> On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution < > swift-evolution@swift.org> wrote:
>
> > What is your evaluation of the proposal?
>
> If this is the last option we have to change the status quo, any
renaming is off the table, no further changes after Swift 4, and it's
either this or being stuck with 'fileprivate' until the end of time, then
+1 from me. It will increase the convenience of access control for people
like me who see types and their extensions as parts of the same entity,
just spread visually across neighboring blocks. In almost any other
language these two would indeed be one entity, since most languages don't
have any way of dividing types into pieces this way.
>
> However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions
about what solutions are under consideration, both now and in the future.
By doing this, I don't mean to pressure you towards any particular stance.
The Core Team asked for this to be proposed because we wanted to know how
the community felt about it; we are not specifically trying to get it
approved, at least as a group.

> 1) Rename 'private' to something else ('scoped'?) and rename
'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the
interpretation of 'private'. 'private' will be tied to scopes, now and
forever. The only question is whether extensions of the same type within a
file should be considered part of the same scope for the purposes of
'private'. Swift 4 is the deadline for making that change; if it, too, is
rejected, 'private' will be purely lexical forever.

> 2) Rename 'fileprivate' to something more friendly (I liked the 'local'
suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace
'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely
for aesthetics; it would have to be because 'fileprivate' seemed
inappropriate for some new generalization, e.g. if we added sub-file
submodules and wanted 'fileprivate' to allow access only within the
submodule. That is assuming a lot about how a future submodule feature
would work, and we aren't going to design that feature specifically with a
goal of replacing this keyword, and frankly we don't know when we're going
to take that on at all. I would caution people against assuming that
'fileprivate' will be renamed.

> 3) Postpone this until we add submodules, but with the assumption that
it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in
future releases of Swift. If some feature — perhaps submodules — demands
that we define its interaction with 'private', the design of that
interaction will have to feel natural and consistent with the at-that-point
extant design of 'private'. For example, it would not be acceptable if,
say, adding a submodule declaration to a file suddenly changed the
interpretation of 'private'.

An option (4) that you didn't list but which I should cover for
completeness would be to add new keywords in the future with new
interpretations. This is something that the Core Team is willing to
consider. However, speaking just for myself again, I find it unlikely that
we would add new access control features just to express
increasingly-precise refinements; it would have to be something that felt
necessary because of some real inadequacy in the existing access-control
levels as applied to some other new feature (e.g. submodules).

John.

> The thing I don't like about this proposal (or status quo) - apart from
the fact that it will make people who like the current strict private
unhappy - is that 'private' even right now means kind of two different
things:
>
> - for a property or a method defined in a class/struct, it means
"available only inside this type"
> - for a private global variable/constant/function, or a private type or
extension, it means "available in this file" i.e. the same as 'fileprivate'
>
> So if we're worried that this proposal makes the meaning of 'private'
unclear - it already is unclear. Wouldn't it be much more clear if private
global variables, functions and classes were required to use the access
level that means "available in this file", since that's how they actually
work? (as long as this level is not named 'fileprivate' :)
>
> And the other access level, the "available only inside this type"
(private / scoped), could only be used for things that are actually
contained inside a type, and wouldn't have two different meanings depending
on whether it's at the root of the file or nested inside something else.
>
> I really believe that even though this is kind of painful for everyone,
it's worth spending time to figure out a solution that satisfies most of us
and makes the language clearer and friendlier in the long term, even if it
means breaking compatibility again. Do we want to be stuck with an
imperfect solution 10 years from now, because we didn't want to do this
last breaking change now?
>
>
> > Is the problem being addressed significant enough to warrant a change
to Swift?
>
> I think almost everyone here agrees it is significant.
>
>
> > Does this proposal fit well with the feel and direction of Swift?
>
> This is a difficult question. IMHO it would definitely fit much better
with the direction of Swift if we bit the bullet and did whatever we agree
will make the language simpler and better long term, regardless how many
changed lines in git this will cause when Swift 4 is released.
>
>
> > If you have used other languages or libraries with a similar feature,
how do you feel that this proposal compares to those?
>
> I've used many languages, but I think in none of them it was a common
thing (or even a possibility) to split types into several blocks like we do
in Swift with extensions, so the main issue we're talking about didn't
exist there. In Ruby you can kind of do the same thing with modules - if
you have a private method in a module, you can access it from methods in
the main type, even if they're defined in a different file. (But Ruby isn't
very strict about access control in general, e.g. it allows you to call
private methods on any object via #send).
>
>
> > How much effort did you put into your review? A glance, a quick
reading, or an in-depth study?
>
> I've read or skimmed through most of the messages in the recent threads
about this and the last proposal.
>
> Disclaimer: I have very little experience with Swift 3 (but plenty with
Swift 2.x).
>
> Kuba
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

On 8 April 2017 at 06:34, John McCall <rjmccall@apple.com> wrote:

> On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution < > swift-evolution@swift.org> wrote:
>
> > What is your evaluation of the proposal?
>
> If this is the last option we have to change the status quo, any
renaming is off the table, no further changes after Swift 4, and it's
either this or being stuck with 'fileprivate' until the end of time, then
+1 from me. It will increase the convenience of access control for people
like me who see types and their extensions as parts of the same entity,
just spread visually across neighboring blocks. In almost any other
language these two would indeed be one entity, since most languages don't
have any way of dividing types into pieces this way.
>
> However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions
about what solutions are under consideration, both now and in the future.
By doing this, I don't mean to pressure you towards any particular stance.
The Core Team asked for this to be proposed because we wanted to know how
the community felt about it; we are not specifically trying to get it
approved, at least as a group.

> 1) Rename 'private' to something else ('scoped'?) and rename
'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the
interpretation of 'private'. 'private' will be tied to scopes, now and
forever. The only question is whether extensions of the same type within a
file should be considered part of the same scope for the purposes of
'private'. Swift 4 is the deadline for making that change; if it, too, is
rejected, 'private' will be purely lexical forever.

> 2) Rename 'fileprivate' to something more friendly (I liked the 'local'
suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace
'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely
for aesthetics; it would have to be because 'fileprivate' seemed
inappropriate for some new generalization, e.g. if we added sub-file
submodules and wanted 'fileprivate' to allow access only within the
submodule. That is assuming a lot about how a future submodule feature
would work, and we aren't going to design that feature specifically with a
goal of replacing this keyword, and frankly we don't know when we're going
to take that on at all. I would caution people against assuming that
'fileprivate' will be renamed.

> 3) Postpone this until we add submodules, but with the assumption that
it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in
future releases of Swift. If some feature — perhaps submodules — demands
that we define its interaction with 'private', the design of that
interaction will have to feel natural and consistent with the at-that-point
extant design of 'private'. For example, it would not be acceptable if,
say, adding a submodule declaration to a file suddenly changed the
interpretation of 'private'.

An option (4) that you didn't list but which I should cover for
completeness would be to add new keywords in the future with new
interpretations. This is something that the Core Team is willing to
consider. However, speaking just for myself again, I find it unlikely that
we would add new access control features just to express
increasingly-precise refinements; it would have to be something that felt
necessary because of some real inadequacy in the existing access-control
levels as applied to some other new feature (e.g. submodules).

John.

> The thing I don't like about this proposal (or status quo) - apart from
the fact that it will make people who like the current strict private
unhappy - is that 'private' even right now means kind of two different
things:
>
> - for a property or a method defined in a class/struct, it means
"available only inside this type"
> - for a private global variable/constant/function, or a private type or
extension, it means "available in this file" i.e. the same as 'fileprivate'
>
> So if we're worried that this proposal makes the meaning of 'private'
unclear - it already is unclear. Wouldn't it be much more clear if private
global variables, functions and classes were required to use the access
level that means "available in this file", since that's how they actually
work? (as long as this level is not named 'fileprivate' :)
>
> And the other access level, the "available only inside this type"
(private / scoped), could only be used for things that are actually
contained inside a type, and wouldn't have two different meanings depending
on whether it's at the root of the file or nested inside something else.
>
> I really believe that even though this is kind of painful for everyone,
it's worth spending time to figure out a solution that satisfies most of us
and makes the language clearer and friendlier in the long term, even if it
means breaking compatibility again. Do we want to be stuck with an
imperfect solution 10 years from now, because we didn't want to do this
last breaking change now?
>
>
> > Is the problem being addressed significant enough to warrant a change
to Swift?
>
> I think almost everyone here agrees it is significant.
>
>
> > Does this proposal fit well with the feel and direction of Swift?
>
> This is a difficult question. IMHO it would definitely fit much better
with the direction of Swift if we bit the bullet and did whatever we agree
will make the language simpler and better long term, regardless how many
changed lines in git this will cause when Swift 4 is released.
>
>
> > If you have used other languages or libraries with a similar feature,
how do you feel that this proposal compares to those?
>
> I've used many languages, but I think in none of them it was a common
thing (or even a possibility) to split types into several blocks like we do
in Swift with extensions, so the main issue we're talking about didn't
exist there. In Ruby you can kind of do the same thing with modules - if
you have a private method in a module, you can access it from methods in
the main type, even if they're defined in a different file. (But Ruby isn't
very strict about access control in general, e.g. it allows you to call
private methods on any object via #send).
>
>
> > How much effort did you put into your review? A glance, a quick
reading, or an in-depth study?
>
> I've read or skimmed through most of the messages in the recent threads
about this and the last proposal.
>
> Disclaimer: I have very little experience with Swift 3 (but plenty with
Swift 2.x).
>
> Kuba
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

So, +1 for me too.

I’m part of the people who didn’t want SE-0025 in the first place, and don’t like any workaround we try to implement to mitigate it, but taking the Core Team decision in account, I feel this is the right thing to do now.

If strong scoped variables are needed, it will always be possible to reintroduce them using a new keyword (I will personally be against such proposal, but it is a possibility).

···

Le 8 avr. 2017 à 06:34, John McCall via swift-evolution <swift-evolution@swift.org> a écrit :

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

I agreed with Charlie, but I think there’s another option.

The access control problems that both SE-0159 and SE-0169 are attempting to address can be resolved not by changing the definition of the existing access modifiers, but refocussing the use of extensions.

One such way would be to introduce a `partial` modifier. It would be similar to C#’s partial modifier. The proposed partial modifier would be purely additive and it would go a long way to mitigate the access control issues inherent in extension-oriented design.

The key characteristics of partial-oriented design would be:

- Partials would allow the splitting of implementations into multiple logical units without the same-file restriction.
- Partial definitions of a type are restricted to same module. If you wish to add functionality to a type external to its defining module, use an extension.
- Partials would provide greater clarity between additive extension and the original implementation.
- Within a partial, private would be type-private.
- Within an extension, private would be scoped-private (the status quo).

I do see that the last two points may introduce some friction. Particularly because:

- Within a partial, fileprivate would be more restrictive than private.
- Within an extension, fileprivate would be less restrictive than private (the status quo).

However, I don’t see these as too challenging for educators or developers as they are differentiated by their top-level scope.

···

On 07/04/2017, 05:57, "Charlie Monroe via swift-evolution" <swift-evolution-bounces@swift.org on behalf of swift-evolution@swift.org> wrote:

    > Simply as long as it's file-based, it's not a solution, it's just another attempt to satisfy some part of the community. I'm not saying that the current access levels are perfect, but I still believe the way to go is to either use submodules, and/or introducing the concept of "protected" members.

If private is required to be tied to types forever and always, then yes,
this proposal should be accepted.

Let's be clear: private is not and will never be tied to types. It is tied
to *scopes*. This proposal has received a lot of responses suggesting that
the proposed rules should be extended to allow extensions in the same
module to access private members, but that fundamentally misunderstands
access modifiers in Swift.

Two things here. First, Swift allows types to be extended after the fact:
outside the same declaration, outside the same file, even outside the same
module. Second, Swift has access modifiers where each level of access is a
superset of the previous. That is, if you change `private let a` to
`fileprivate let a`, there is no place where `a` becomes no longer
accessible; the same goes for each pair of access modifiers. These two
design decisions are, as far as I'm aware, "now and forever" aspects of
Swift.

Given that these two things are true, *no access modifier is or can be tied
to types*. This proposal is about extending the meaning of *scope* to
include same-file extensions. If you try to think of private as a
type-private modifier, you will invariably conclude that it is broken,
because you can't see private members in extensions outside the same scope.
You will also see the proposed private as broken, only less so, because you
can't see private members in extensions outside the same file. However,
unless I'm greatly mistaken, it is not the intention of this or any other
proposal to create an access level tied to types.

To do otherwise is to suggest that the use of "private" by beginners and

···

On Sat, Apr 8, 2017 at 12:01 AM, BJ Homer via swift-evolution < swift-evolution@swift.org> wrote:

the use of same-file extensions by beginners are incompatible. The former
is silly; "private" is what beginners will naturally reach for. The latter
is possible, but historically the use of same-file extensions has been
quite idiomatic. So, I reluctantly agree we should accept this proposal.

-BJ

> On Apr 7, 2017, at 10:34 PM, John McCall via swift-evolution < > swift-evolution@swift.org> wrote:
>
>
>>> On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution < > swift-evolution@swift.org> wrote:
>>>
>>> What is your evaluation of the proposal?
>>
>> If this is the last option we have to change the status quo, any
renaming is off the table, no further changes after Swift 4, and it's
either this or being stuck with 'fileprivate' until the end of time, then
+1 from me. It will increase the convenience of access control for people
like me who see types and their extensions as parts of the same entity,
just spread visually across neighboring blocks. In almost any other
language these two would indeed be one entity, since most languages don't
have any way of dividing types into pieces this way.
>>
>> However, IMHO any of these would be a better solution:
>
> I'd like to respond briefly to this to clarify the Core Team's decisions
about what solutions are under consideration, both now and in the future.
By doing this, I don't mean to pressure you towards any particular stance.
The Core Team asked for this to be proposed because we wanted to know how
the community felt about it; we are not specifically trying to get it
approved, at least as a group.
>
>> 1) Rename 'private' to something else ('scoped'?) and rename
'fileprivate' back to 'private'
>
> The Core Team has rejected making such a major change in the
interpretation of 'private'. 'private' will be tied to scopes, now and
forever. The only question is whether extensions of the same type within a
file should be considered part of the same scope for the purposes of
'private'. Swift 4 is the deadline for making that change; if it, too, is
rejected, 'private' will be purely lexical forever.
>
>> 2) Rename 'fileprivate' to something more friendly (I liked the 'local'
suggestion that Vladimir made today)
>
> The Core Team is willing to consider adding a new keyword to replace
'fileprivate', but not in Swift 4.
>
> Speaking just for myself, I don't think we'd accept such a change purely
for aesthetics; it would have to be because 'fileprivate' seemed
inappropriate for some new generalization, e.g. if we added sub-file
submodules and wanted 'fileprivate' to allow access only within the
submodule. That is assuming a lot about how a future submodule feature
would work, and we aren't going to design that feature specifically with a
goal of replacing this keyword, and frankly we don't know when we're going
to take that on at all. I would caution people against assuming that
'fileprivate' will be renamed.
>
>> 3) Postpone this until we add submodules, but with the assumption that
it will be possible to make some source-breaking changes at that point
>
> The Core Team is not willing to change the basic design of 'private' in
future releases of Swift. If some feature — perhaps submodules — demands
that we define its interaction with 'private', the design of that
interaction will have to feel natural and consistent with the at-that-point
extant design of 'private'. For example, it would not be acceptable if,
say, adding a submodule declaration to a file suddenly changed the
interpretation of 'private'.
>
> An option (4) that you didn't list but which I should cover for
completeness would be to add new keywords in the future with new
interpretations. This is something that the Core Team is willing to
consider. However, speaking just for myself again, I find it unlikely that
we would add new access control features just to express
increasingly-precise refinements; it would have to be something that felt
necessary because of some real inadequacy in the existing access-control
levels as applied to some other new feature (e.g. submodules).
>
> John.
>
>> The thing I don't like about this proposal (or status quo) - apart from
the fact that it will make people who like the current strict private
unhappy - is that 'private' even right now means kind of two different
things:
>>
>> - for a property or a method defined in a class/struct, it means
"available only inside this type"
>> - for a private global variable/constant/function, or a private type or
extension, it means "available in this file" i.e. the same as 'fileprivate'
>>
>> So if we're worried that this proposal makes the meaning of 'private'
unclear - it already is unclear. Wouldn't it be much more clear if private
global variables, functions and classes were required to use the access
level that means "available in this file", since that's how they actually
work? (as long as this level is not named 'fileprivate' :)
>>
>> And the other access level, the "available only inside this type"
(private / scoped), could only be used for things that are actually
contained inside a type, and wouldn't have two different meanings depending
on whether it's at the root of the file or nested inside something else.
>>
>> I really believe that even though this is kind of painful for everyone,
it's worth spending time to figure out a solution that satisfies most of us
and makes the language clearer and friendlier in the long term, even if it
means breaking compatibility again. Do we want to be stuck with an
imperfect solution 10 years from now, because we didn't want to do this
last breaking change now?
>>
>>
>>> Is the problem being addressed significant enough to warrant a change
to Swift?
>>
>> I think almost everyone here agrees it is significant.
>>
>>
>>> Does this proposal fit well with the feel and direction of Swift?
>>
>> This is a difficult question. IMHO it would definitely fit much better
with the direction of Swift if we bit the bullet and did whatever we agree
will make the language simpler and better long term, regardless how many
changed lines in git this will cause when Swift 4 is released.
>>
>>
>>> If you have used other languages or libraries with a similar feature,
how do you feel that this proposal compares to those?
>>
>> I've used many languages, but I think in none of them it was a common
thing (or even a possibility) to split types into several blocks like we do
in Swift with extensions, so the main issue we're talking about didn't
exist there. In Ruby you can kind of do the same thing with modules - if
you have a private method in a module, you can access it from methods in
the main type, even if they're defined in a different file. (But Ruby isn't
very strict about access control in general, e.g. it allows you to call
private methods on any object via #send).
>>
>>
>>> How much effort did you put into your review? A glance, a quick
reading, or an in-depth study?
>>
>> I've read or skimmed through most of the messages in the recent threads
about this and the last proposal.
>>
>> Disclaimer: I have very little experience with Swift 3 (but plenty with
Swift 2.x).
>>
>> Kuba
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution@swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

>
> > What is your evaluation of the proposal?
>
> If this is the last option we have to change the status quo, any
renaming is off the table, no further changes after Swift 4, and it's
either this or being stuck with 'fileprivate' until the end of time, then
+1 from me. It will increase the convenience of access control for people
like me who see types and their extensions as parts of the same entity,
just spread visually across neighboring blocks. In almost any other
language these two would indeed be one entity, since most languages don't
have any way of dividing types into pieces this way.
>
> However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions
about what solutions are under consideration, both now and in the future.
By doing this, I don't mean to pressure you towards any particular stance.
The Core Team asked for this to be proposed because we wanted to know how
the community felt about it; we are not specifically trying to get it
approved, at least as a group.

> 1) Rename 'private' to something else ('scoped'?) and rename
'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the
interpretation of 'private'. 'private' will be tied to scopes, now and
forever. The only question is whether extensions of the same type within a
file should be considered part of the same scope for the purposes of
'private'. Swift 4 is the deadline for making that change; if it, too, is
rejected, 'private' will be purely lexical forever.

> 2) Rename 'fileprivate' to something more friendly (I liked the 'local'
suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace
'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely
for aesthetics;

If I recall correctly, Chris in post-review discussions communicated that a
new keyword to replace `fileprivate` would be considered if `fileprivate`
turned out to be commonly used enough to be aesthetically problematic?

I bring this up because, in replying to BJ Homer, it occurs to me that
there is an interesting solution. If--as I understand--successive access
modifiers being supersets of preceding ones is a non-negotiable part of the
design, then type-based access modifiers cannot be accommodated in Swift
because of the existence of extensions. Ergo, the word "protected" cannot
ever be used to mean what it does in C++, etc. It is a perfectly nice word
that by its dictionary meaning is plausibly intermediate between "private"
and "internal," which we can repurpose to mean protected by the end of
file! By co-opting this word, it has the key virtue of definitively
demonstrating that Swift cannot and will not support access modifiers that
are tied to types.

it would have to be because 'fileprivate' seemed inappropriate for some new

···

On Fri, Apr 7, 2017 at 11:34 PM, John McCall via swift-evolution < swift-evolution@swift.org> wrote:

> On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution < > swift-evolution@swift.org> wrote:
generalization, e.g. if we added sub-file submodules and wanted
'fileprivate' to allow access only within the submodule. That is assuming
a lot about how a future submodule feature would work, and we aren't going
to design that feature specifically with a goal of replacing this keyword,
and frankly we don't know when we're going to take that on at all. I would
caution people against assuming that 'fileprivate' will be renamed.

> 3) Postpone this until we add submodules, but with the assumption that
it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in
future releases of Swift. If some feature — perhaps submodules — demands
that we define its interaction with 'private', the design of that
interaction will have to feel natural and consistent with the at-that-point
extant design of 'private'. For example, it would not be acceptable if,
say, adding a submodule declaration to a file suddenly changed the
interpretation of 'private'.

An option (4) that you didn't list but which I should cover for
completeness would be to add new keywords in the future with new
interpretations. This is something that the Core Team is willing to
consider. However, speaking just for myself again, I find it unlikely that
we would add new access control features just to express
increasingly-precise refinements; it would have to be something that felt
necessary because of some real inadequacy in the existing access-control
levels as applied to some other new feature (e.g. submodules).

John.

> The thing I don't like about this proposal (or status quo) - apart from
the fact that it will make people who like the current strict private
unhappy - is that 'private' even right now means kind of two different
things:
>
> - for a property or a method defined in a class/struct, it means
"available only inside this type"
> - for a private global variable/constant/function, or a private type or
extension, it means "available in this file" i.e. the same as 'fileprivate'
>
> So if we're worried that this proposal makes the meaning of 'private'
unclear - it already is unclear. Wouldn't it be much more clear if private
global variables, functions and classes were required to use the access
level that means "available in this file", since that's how they actually
work? (as long as this level is not named 'fileprivate' :)
>
> And the other access level, the "available only inside this type"
(private / scoped), could only be used for things that are actually
contained inside a type, and wouldn't have two different meanings depending
on whether it's at the root of the file or nested inside something else.
>
> I really believe that even though this is kind of painful for everyone,
it's worth spending time to figure out a solution that satisfies most of us
and makes the language clearer and friendlier in the long term, even if it
means breaking compatibility again. Do we want to be stuck with an
imperfect solution 10 years from now, because we didn't want to do this
last breaking change now?
>
>
> > Is the problem being addressed significant enough to warrant a change
to Swift?
>
> I think almost everyone here agrees it is significant.
>
>
> > Does this proposal fit well with the feel and direction of Swift?
>
> This is a difficult question. IMHO it would definitely fit much better
with the direction of Swift if we bit the bullet and did whatever we agree
will make the language simpler and better long term, regardless how many
changed lines in git this will cause when Swift 4 is released.
>
>
> > If you have used other languages or libraries with a similar feature,
how do you feel that this proposal compares to those?
>
> I've used many languages, but I think in none of them it was a common
thing (or even a possibility) to split types into several blocks like we do
in Swift with extensions, so the main issue we're talking about didn't
exist there. In Ruby you can kind of do the same thing with modules - if
you have a private method in a module, you can access it from methods in
the main type, even if they're defined in a different file. (But Ruby isn't
very strict about access control in general, e.g. it allows you to call
private methods on any object via #send).
>
>
> > How much effort did you put into your review? A glance, a quick
reading, or an in-depth study?
>
> I've read or skimmed through most of the messages in the recent threads
about this and the last proposal.
>
> Disclaimer: I have very little experience with Swift 3 (but plenty with
Swift 2.x).
>
> Kuba
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution@swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

If a lot of people (core team included) agree that the current design is less than ideal...why lock in something so important that can never be changed going forward?

Why not get it right and force something source breaking that would improve the language for everyone going forward?

The language is still, after all, very young.

I understand the problem it would cause but this isn't like breaking everyone's code 10 years later. It's still a fresh language

I'm probably missing some of the complexity and politics behind doing something like this, but it just seems like doing the right thing is more beneficial in the long run

Brandon

···

On Apr 8, 2017, at 12:34 AM, John McCall via swift-evolution <swift-evolution@swift.org> wrote:

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org> wrote:

What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

What is your evaluation of the proposal?

If this is the last option we have to change the status quo, any renaming is off the table, no further changes after Swift 4, and it's either this or being stuck with 'fileprivate' until the end of time, then +1 from me. It will increase the convenience of access control for people like me who see types and their extensions as parts of the same entity, just spread visually across neighboring blocks. In almost any other language these two would indeed be one entity, since most languages don't have any way of dividing types into pieces this way.

However, IMHO any of these would be a better solution:

I'd like to respond briefly to this to clarify the Core Team's decisions about what solutions are under consideration, both now and in the future. By doing this, I don't mean to pressure you towards any particular stance. The Core Team asked for this to be proposed because we wanted to know how the community felt about it; we are not specifically trying to get it approved, at least as a group.

1) Rename 'private' to something else ('scoped'?) and rename 'fileprivate' back to 'private'

The Core Team has rejected making such a major change in the interpretation of 'private'. 'private' will be tied to scopes, now and forever. The only question is whether extensions of the same type within a file should be considered part of the same scope for the purposes of 'private'. Swift 4 is the deadline for making that change; if it, too, is rejected, 'private' will be purely lexical forever.

With this being the case, I want to revise my response to +1. It allows the flexibility required for the extension-rich architecture Swift open adopts with protocol conformance and I think that’s a good thing, personally.

···

On 8 Apr 2017, at 2:34 pm, John McCall via swift-evolution <swift-evolution@swift.org> wrote:

On Apr 7, 2017, at 8:12 PM, Jakub Suder via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

2) Rename 'fileprivate' to something more friendly (I liked the 'local' suggestion that Vladimir made today)

The Core Team is willing to consider adding a new keyword to replace 'fileprivate', but not in Swift 4.

Speaking just for myself, I don't think we'd accept such a change purely for aesthetics; it would have to be because 'fileprivate' seemed inappropriate for some new generalization, e.g. if we added sub-file submodules and wanted 'fileprivate' to allow access only within the submodule. That is assuming a lot about how a future submodule feature would work, and we aren't going to design that feature specifically with a goal of replacing this keyword, and frankly we don't know when we're going to take that on at all. I would caution people against assuming that 'fileprivate' will be renamed.

3) Postpone this until we add submodules, but with the assumption that it will be possible to make some source-breaking changes at that point

The Core Team is not willing to change the basic design of 'private' in future releases of Swift. If some feature — perhaps submodules — demands that we define its interaction with 'private', the design of that interaction will have to feel natural and consistent with the at-that-point extant design of 'private'. For example, it would not be acceptable if, say, adding a submodule declaration to a file suddenly changed the interpretation of 'private'.

An option (4) that you didn't list but which I should cover for completeness would be to add new keywords in the future with new interpretations. This is something that the Core Team is willing to consider. However, speaking just for myself again, I find it unlikely that we would add new access control features just to express increasingly-precise refinements; it would have to be something that felt necessary because of some real inadequacy in the existing access-control levels as applied to some other new feature (e.g. submodules).

John.

The thing I don't like about this proposal (or status quo) - apart from the fact that it will make people who like the current strict private unhappy - is that 'private' even right now means kind of two different things:

- for a property or a method defined in a class/struct, it means "available only inside this type"
- for a private global variable/constant/function, or a private type or extension, it means "available in this file" i.e. the same as 'fileprivate'

So if we're worried that this proposal makes the meaning of 'private' unclear - it already is unclear. Wouldn't it be much more clear if private global variables, functions and classes were required to use the access level that means "available in this file", since that's how they actually work? (as long as this level is not named 'fileprivate' :)

And the other access level, the "available only inside this type" (private / scoped), could only be used for things that are actually contained inside a type, and wouldn't have two different meanings depending on whether it's at the root of the file or nested inside something else.

I really believe that even though this is kind of painful for everyone, it's worth spending time to figure out a solution that satisfies most of us and makes the language clearer and friendlier in the long term, even if it means breaking compatibility again. Do we want to be stuck with an imperfect solution 10 years from now, because we didn't want to do this last breaking change now?

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

I think almost everyone here agrees it is significant.

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

This is a difficult question. IMHO it would definitely fit much better with the direction of Swift if we bit the bullet and did whatever we agree will make the language simpler and better long term, regardless how many changed lines in git this will cause when Swift 4 is released.

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

I've used many languages, but I think in none of them it was a common thing (or even a possibility) to split types into several blocks like we do in Swift with extensions, so the main issue we're talking about didn't exist there. In Ruby you can kind of do the same thing with modules - if you have a private method in a module, you can access it from methods in the main type, even if they're defined in a different file. (But Ruby isn't very strict about access control in general, e.g. it allows you to call private methods on any object via #send).

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

I've read or skimmed through most of the messages in the recent threads about this and the last proposal.

Disclaimer: I have very little experience with Swift 3 (but plenty with Swift 2.x).

Kuba

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

Strong -1. This is a source breaking change, but Swift 4 stage 2 is already over.

I agree with you here. I don't think the proposal will be accepted as is, because of the breaking change.

What if there was a way to make this a new feature so it is not a breaking change?

I can see this same proposal being accepted if it was revised to mark the new extension behavior explicitly.

Type.swift

struct A {
  private func foo() {}
}

*partial* extension A { // any other keyword would do here or even \
  func baz() {
    foo() // okay
  }
}

extension A {
  func boo() {
    foo() // error. Same as swift 3.
  }
}

Other.swift

*partial* extension A { // error. Partial extensions only allowed within the declaring file.
}

extension A {
  func boo() {
    foo() // error. Same as swift 3.
  }
}

···

On Apr 6, 2017, at 4:25 PM, Slava Pestov via swift-evolution <swift-evolution@swift.org> wrote:

Slava

On Apr 6, 2017, at 4:10 PM, Douglas Gregor <dgregor@apple.com <mailto:dgregor@apple.com>> wrote:

Hello Swift community,

The review of SE-0169 "Improve Interaction Between private Declarations and Extensions" begins now and runs through April 11, 2017. The proposal is available here:

https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.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. When replying, please try to keep the proposal link at the top of the message:

Proposal link:

https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md
Reply text
Other replies
<https://github.com/apple/swift-evolution/blob/master/process.md#what-goes-into-a-review-1&gt;What goes into a review?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine 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,

-Doug

Review Manager

_______________________________________________
swift-evolution-announce mailing list
swift-evolution-announce@swift.org <mailto:swift-evolution-announce@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution-announce

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

-1 (strong)

I think I've read all messages and haven't much to add — so just to sum up my concerns in order:
— It makes access control more complicated
For me, it's not about the complexity itself (it's not terrible huge, after all), but I believe in the beauty of simplicity, which is already quite flawed.
— It adds no power to the language
The proposal solves no real problem, but rather encourages a certain style of programming, which is quite popular among authors of styleguides, but has no clear net gain.

While your other points are defendable, I have to disagree here. It does bring value to a population of developers (me included) for whom that style of programming adds a lot of readability. It's part of style guides for a reason.

— It diminishes the need for fileprivate without making it redundant
It would be nice to get rid of an access level, but having four common ones and fileprivate as an exotic outlier doesn't feel right for me.

Doesn't the argument of progressive disclosure sway you here? open is already an outlier that only library authors will play with, and that's a good thing. It reduces the number of access level truly useful on a day to day basis, while leaving the others for more narrow purposes.

···

On 11 Apr 2017, at 08:48, Tino Heth via swift-evolution <swift-evolution@swift.org> wrote:

— It is a mockery for SE-0025
I never liked "new private", but it was decided that this sort of encapsulation is important enough to justify 33% increase in the number of access levels, so I don't like to see this watered down
— It is a breaking change
For me personally, that doesn't really count as an argument on its own, and I would gladly take the inconvenience of incompatibility in exchange for a tiny improvement of the language; but in combination with the other points, it increases opposition.

I spend some time thinking about nested extensions (which would achieve the goal of this proposal naturally) and think that SE-0169 would lead to some questionable possibilities of short-circuiting access control:

class Outer {
  private class Inner {
    private var x = 0
  }
}

/*
.
.
.
*/

extension Outer.Inner {
  public func f() {
    print(x)
  }
}

As I read the proposal, there is no doubt that this would be allowed — but without that detailed information, I'm not sure if anybody would expect that two levels of private still is not enough to keep something secret…

- Tino
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Well summarised Tino, I agree with all arguments.
Strong -1 from me, too.

-1 (strong)

I think I've read all messages and haven't much to add — so just to sum up my concerns in order:
— It makes access control more complicated
— It adds no power to the language
— It diminishes the need for fileprivate without making it redundant
— It is a mockery for SE-0025
— It is a breaking change

If we want to encourage separating several aspects of one type into multiple extensions, then we should try a different approach.
When we allow to also introduce new member variables in extensions, then we could make them private while still keeping them local to the member functions which access them.

This approach has other downsides but I think we can cope with them.
Biggest disadvantage would be that the storage size is not immediately visible from the type definition.
We could require some marker (`partial class` / `extension class` / whatever) so that everybody can immediately see that there may be extensions with additional storage.

E.g.:

    partial class Foo {}

    extension Foo {
        private var i = 0
        func bar() {
            print(i)
            i += 1
        }
    }
    extension Foo {
        private var j = 1
        func baz() {
            print(j)
            j -= 1
        }
    }

When we want any distinction between `private` and `fileprivate`, then these two extensions should not see each others private members.
Of course the other workaround would be to remove the distinction altogether and make private an alias for fileprivate.

···

Am 11.04.2017 um 08:48 schrieb Tino Heth via swift-evolution <swift-evolution@swift.org>:


Martin

-1 from me.

Using extensions for "code organization" is another word for writing spaghetti code.

It results in types with many responsibilities. In such cases, it's time to extract collaborator types.

But it sure looks prettier.

R+

···

Sent from my iPhone

On 7 Apr 2017, at 10:56, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

What is your evaluation of the proposal?

Strong -1. Just rename ‘fileprivate’ to be less annoying.

This proposal will make things even worse than they are currently. We will regret it just as much, if not more than, 0025. As others have mentioned, it is actively harmful:
• It once again changes the meaning of private
• It takes away most of the actual power of private (vs fileprivate). (I was for returning to the simpler Swift 2 access, but when I did use private, I used it to limit access to just a few lines of code. This proposal gets rid of the last ounce of usefulness of ‘private’ for me, and only has the virtue of a less annoying name).
• It is the camel’s nose in the tent for type-based access (people will ask for future versions to be available in the type in the submodule, module, and then public… but we will be unable to give it to them)
• It breaks the same code that 0159 would have broken
• It will be a nightmare to teach/learn

Also, the idea that we should limit the use of ‘fileprivate’ is incorrect. Fileprivate is the best access levels for a lot of cases, it just has an annoying name. Given our constraints, I now believe the only sane choice left to us is to make fileprivate easier to use (as opposed to making private more like it) and to get rid of the cognitive dissonance of having similar names/concepts by renaming ‘fileprivate’ to something like ‘local’. ‘fileprivate’ (whatever it is called) should be the soft-default. ‘private’ should be the one being used explicitly.

We are likely going to have to rename ‘fileprivate’ anyway to work with submodules (that or add another access level), and ‘local’ has connotations of visible nearby… so I think it works well enough.

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

Yes, access controls are a mess… but this will make them more of a mess.

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

No.

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

No. I have used languages with type-based private, and I have used languages with file-based private… but never type-based that was limited to a file. You got shrimp in my chocolate (not all great tastes go well together).

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

I have followed the discussion closely and spent a great deal of time thinking about it.

Thanks,
Jon

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Two answers:

1. I would then have to expose the "fragile part" type, which is really an implementation detail of the other type, to the entire `internal` namespace.

2. In that scenario, I would get exactly the same amount of safety from `fileprivate`. This proposal's definition of `private` gives me nothing.

···

On Apr 7, 2017, at 12:56 AM, Jean-Daniel <mailing@xenonium.com> wrote:

Even though I think we were better off without scoped `private`, I *have* used it fruitfully on several occasions. These were typically in places where I wanted to restrict access to a small number of members which I could ensure would enforce certain invariants. An example I gave previously involved two arrays which contained matching elements; code should never insert or remove from one array without doing the same to the other. By making these arrays `private` and exposing `fileprivate` and `public` members derived from them, I could ensure that only a couple dozen lines could possibly contain such a bug without changing the external design of the type or introducing boilerplate.

This proposal does not offer the same utility. The only way to protect fragile parts of a type from other parts is to extract them into a separate type, and even then, you can extend that new type anywhere in the file to access the fragile parts. You're also likely to end up having members on the outer type which simply call into equivalent members on the inner type. It increases boilerplate and reduces protection.

What about using 2 files ? One for private fragile part, one for ‘public’ part.

--
Brent Royal-Gordon
Architechies

We were told we can’t do the double rename. I believe renaming ‘fileprivate’ is still on the table (or at least it will have to be at some point when we consider submodules).

If renaming ‘fileprivate’ is truly off the table, we should definitely NOT accept this proposal (for all the reasons I and others have stated). We should keep the status quo, horrible as it may be.

···

On Apr 7, 2017, at 3:51 AM, Goffredo Marocchi <panajev@gmail.com> wrote:

Sent from my iPhone

On 7 Apr 2017, at 09:56, Jonathan Hull via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

What is your evaluation of the proposal?

Strong -1. Just rename ‘fileprivate’ to be less annoying.

So, we keep being told it won't happen and our current Bly suggestion discussing this proposal cannot be to just keep asking for it, can it?

I think that is why he is saying (and I agree), that ‘fileprivate’ needs to be the soft-default. That way private will mean something.

His point that this gets rid of the primary use-case of ‘private’ (over ‘fileprivate’) is also extremely relevant.

···

On Apr 7, 2017, at 4:51 AM, Gwendal Roué via swift-evolution <swift-evolution@swift.org> wrote:

Le 7 avr. 2017 à 13:44, Matthew Johnson via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> a écrit :

No. I believe it makes the language worse, not better. It doesn’t address the real problems with access control. The largest problem is the inability to form scopes between files and the entire module. The problem with `fileprivate` and `private` is a naming problem, not a semantics problem.

This is the base of your argument, and I think it is wrong, considering that code is a living matter, not a static one.

Too many properties initially declared as `private` have to be declared `fileprivate` later, because the code is evolving. And this change is usually performed just to tame a compiler error.

This is why the current private/fileprivate situation is actually a semantics problem. Private is not stable enough to mean anything.

Gwendal Roué

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

-1 for reasons I've previously expressed in the discussions:

- It encourages everything to be stuffed in one file.
- It doesn't actually solve anything as the new private is very close to fileprivate, while abolishing private as truly scoped - which is a tool I use on regular basis.

Simply as long as it's file-based, it's not a solution, it's just another attempt to satisfy some part of the community. I'm not saying that the current access levels are perfect, but I still believe the way to go is to either use submodules, and/or introducing the concept of "protected" members.

+1 to the proposal.

How will submodules discourage stuffing everything into one file?
I can only think of creating a submodule per each class which doesn't look like a good solution.

It's no better solution than this proposal.

I think this proposal is a step in the right direction. 'private' becomes type-based

No, not really. Only partly - and that's the issue I have with this proposal.

BTW the proposal doesn't address this:

class Foo {
  private func joo() { ... }
}

extension Foo {
  private func zoo() { ... }
}

class Bar: Foo {
  // Can I access joo() and zoo() here?
}

and the only thing left to do is extending it to extensions in the module in the future.

And what if you want a member not to be visible to extensions outside the file?

This is absolutely orthogonal issue that can be solved by the protected access level, which can allow you whether the member is seen by extensions/subclasses. No matter what file within the module.

···

On Apr 7, 2017, at 10:35 AM, Andrey Fidrya <af@zabiyaka.com> wrote:

On 7 Apr 2017, at 07:57, Charlie Monroe via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Andrey

On Apr 7, 2017, at 1:10 AM, Douglas Gregor via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Hello Swift community,

The review of SE-0169 "Improve Interaction Between private Declarations and Extensions" begins now and runs through April 11, 2017. The proposal is available here:

https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.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. When replying, please try to keep the proposal link at the top of the message:

Proposal link:

https://github.com/apple/swift-evolution/blob/master/proposals/0169-improve-interaction-between-private-declarations-and-extensions.md
Reply text
Other replies
<https://github.com/apple/swift-evolution/blob/master/process.md#what-goes-into-a-review-1&gt;What goes into a review?

The goal of the review process is to improve the proposal under review through constructive criticism and, eventually, determine 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,

-Doug

Review Manager

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution