private & fileprivate

Beyond the textual change of using a different modifier name, I don’t see how the encapsulation and organization of code could be affected. Really, there’s not much point in rehashing prior discussion of SE-0025 unless there’s a previously unconsidered angle.

Preston

···

On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution <swift-evolution@swift.org> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me <mailto:zach@waldowski.me>

SE-0025 was *very* heavily discussed, and while many people were not
satisfied with the solution we went with (including me!), it was what
the core team and community converged on.

Politely playing the Devil's Advocate: it was still fairly early on in
the lifecycle of swift-evolution, particularly for the 3 cycle; the
discussion was heavily weighted towards the people who wanted a change,
versus those who were happy with the status quo. I don't like playing
the Silent Majority card, as it's a horribly weak fallacy, but it is
what it is.

(responding up-thread now to William…)

Really, there’s not much point in rehashing prior discussion of SE-
0025 unless there’s a previously unconsidered angle.

The new information is that Swift 3 is in the wild. People have gotten
to use it, users both new and old, and have been dismayed and confused,
respectively, with the change.

I appreciate the need for the community to keep pushing forward and not
constantly revisit and counter-proposal things, I really do. It's why I
was glad it seemed like "requiring `self.`" was laid to bed so
conclusively. But this isn't like C-style for loops, I'm not clinging to
my guns and incrementors; we've taken something that enjoyed a quite
simple mental model, even though it was limited compared to other
languages, and made it arbitrarily more complex.

Having come to a consensus (which I disagree happened; more the clock
ran ) shouldn't mean it's locked in stone forever. In fact, the
potential for reconsidering was mentioned by many in response to the
blowback to sealed-by-default, and was used for justification as to why
it "had" to be considered for Swift 3.

It's important to recognize our mistakes and not get into the trap of
thinking the mailing list is the ground truth of all Swift users.

Best —
Zach

···

On Fri, Oct 7, 2016, at 03:56 PM, Jordan Rose wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution <swift- >>> evolution@swift.org> wrote:

While I agree that private/fileprivate didn't change much… I have to say
that I wish we had simply kept private as is and ended up with private,
internal, public, and open. It is more tricky to explain than it is worth.

TJ

···

On Fri, Oct 7, 2016 at 6:56 PM, Jordan Rose via swift-evolution < swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution < > swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution < > swift-evolution@swift.org> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has
its uses (which is why the proposal got traction in the first place), but
when combined with the other access levels, the language feature as a whole
feels arbitrary. In practical use, files that I felt were nicely
encapsulated and hiding implementation details are now a scattered mix of
access levels, adding cognitive load and making the code look unorganized
for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

Beyond the textual change of using a different modifier name, I don’t see
how the encapsulation and organization of code could be affected. Really,
there’s not much point in rehashing prior discussion of SE-0025 unless
there’s a previously unconsidered angle.

I *strongly* agree with this sentiment. SE-0025 was *very* heavily
discussed, and while many people were not satisfied with the solution we
went with (including me!), it was what the core team and community
converged on. I don't expect us to change access control again until and
unless we decide to change the model in some way, and even then I think
we'll want to go through extra effort to maintain compatibility with Swift
3. As has been mentioned repeatedly, the bar for source-breaking changes is
much higher than it was in the first few months of swift-evolution.

I actually consider it very lucky that most of our changes so far have
been fairly non-controversial. Everybody has a different idea of what would
make Swift a better language, and all of us well-meaning. But when those
ideas conflict, some group is going to end up unhappy. I'm actually very
glad that (a) we haven't had too many of these cases, and (b) even when we
have, people have been able to accept it and move on to contributing to the
next issue.

Jordan

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

Private access that limits exposure to extensions and subclasses is
the bane of reusability. It sucks in Java and it sucks in Swift. As
far as I know Ruby is the only language that seems to get that.

So are folks saying remove the concept of file private and keep the new
private behavior? ...or revert the whole thing? Also based on what do we
really see an issue with the addition of fileprivate? It seems more theory
then examples of problems in the discussions I have seen.

-Shawn

···

On Fri, Oct 7, 2016 at 2:05 PM Zach Waldowski via swift-evolution < swift-evolution@swift.org> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has
its uses (which is why the proposal got traction in the first place), but
when combined with the other access levels, the language feature as a whole
feels arbitrary. In practical use, files that I felt were nicely
encapsulated and hiding implementation details are now a scattered mix of
access levels, adding cognitive load and making the code look unorganized
for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

On Fri, Oct 7, 2016, at 01:55 PM, Russ Bishop via swift-evolution wrote:

On Oct 7, 2016, at 9:13 AM, David Hart via swift-evolution < > swift-evolution@swift.org> wrote:

I started the topic, but I also believe like you that the *fileprivate*
vs *private(file)* discussion has already been thoroughly discussed and
nothing new has been brought up. That’s not what I want to discuss.

I instead want to share my experience using *private* and *fileprivate*
since release. Here are my thoughts:

   1. We should start with the premise that the proposal has added a
   substantial amount of complexity:
   1. It has added an extra modifier and access level to learn.
      2. It has complicated the access level rules with Inner types as
      mentioned in the *Complications with private types* section of the
      proposal.
      3. I have seen many people (twitter, work, slack) be confused about
      the difference between *private* and *fileprivate* at the global
      level. The answer is none, which shows that both modifiers are not very
      orthogonal.
      4. Since release, I saw people prefer one over the other, as a
      matter of style. They tend to always use *fileprivate* or always
      using *private*. In the latter case, functions and properties get
      clumped in the same class scope instead of be written through multiple
      extensions.
      2. I have the impression that the motivations for the proposal are
   much less real in practice:
   1. The first motivation stated is: *"It is not clear whether the
      implementation details are meant to be completely hidden or can be shared
      with some related code without the danger of misusing the APIs marked as
      private.”* I’ve found that to be fairly rare in practice because
      the implementation details only used to leak inside the same file, which
      greatly reduces the dangers.
      2. The second motivation stated is: *"It forces a one class per
      file structure, which is very limiting." *First of all, this is
      partly false. I think it forces putting classes which share implementation
      details in the same file, which I don’t think is necessarily a bad thing.

To summarise, it seems that the confusion the proposal brought over
semantics and style are not worth the limited benefits that it brought. I’d
be tempted to backtrack the proposal and re-introduce private as a file
scoped access-level and deprecate fileprivate.

Thoughts?
David.

I agree. The minor benefit that fileprivate brings is not worth the
cognitive overhead it introduces. We should just admit it was a mistake and
back it out. We can avoid source-breaking changes by making fileprivate a
synonym for private and provide fixits/warnings for a release to give
people a chance to move off it.

Russ

*_______________________________________________*
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

I actually feel exactly the opposite of this—personally I thought `private`
was fine the way it was when it meant `fileprivate` and I had no real need
for `private` as it exists in Swift 3.

`fileprivate` is useful because it lets me organize my code in such a way
that I divide large types (for example, those that conform to many
delegates/other protocols) into multiple extensions in the same file. Any
state or helpers that I want to keep in the main class can be defined as
`fileprivate` and still be accessible throughout that file, without leaking
them into the rest of my module if they were defined as `internal`.

On the other hand, `private` would mostly just protect me from myself at a
very small level. In all the Swift code that I've written (this is my
anecdotal experience, of course, and I know others differ), it's rare that
I've found a strong reason to or benefit from locking something down as
`private` instead of `fileprivate`.

Of course, one could argue that `fileprivate` is also protecting me from
myself, just a file-based level instead of a scope-based level, but I think
it would be more harmful to encourage leaking abstractions out of a file
and into a module than it would to leak them out of a scope and into a
single file. The affected surface area is much smaller in the latter case.

One possible compromise that pops into my head would be to let `private`
not apply to a scope but to a type and also to only those extensions on
that type that are visible in the same file—that may have already been
discussed during the review of the original proposal. I don't know what the
complexity of it would be.

Either way, I would be strongly against anything that removes
`fileprivate`. I don't find much use for `private` and nobody is forcing me
to use it, so I don't. On the other hand, removing `fileprivate` would
prevent a design and code organization pattern that I enjoy about Swift.

···

On Fri, Oct 7, 2016 at 2:06 PM Zach Waldowski via swift-evolution < swift-evolution@swift.org> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has
its uses (which is why the proposal got traction in the first place), but
when combined with the other access levels, the language feature as a whole
feels arbitrary. In practical use, files that I felt were nicely
encapsulated and hiding implementation details are now a scattered mix of
access levels, adding cognitive load and making the code look unorganized
for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

On Fri, Oct 7, 2016, at 01:55 PM, Russ Bishop via swift-evolution wrote:

On Oct 7, 2016, at 9:13 AM, David Hart via swift-evolution < > swift-evolution@swift.org> wrote:

I started the topic, but I also believe like you that the *fileprivate*
vs *private(file)* discussion has already been thoroughly discussed and
nothing new has been brought up. That’s not what I want to discuss.

I instead want to share my experience using *private* and *fileprivate*
since release. Here are my thoughts:

   1. We should start with the premise that the proposal has added a
   substantial amount of complexity:
   1. It has added an extra modifier and access level to learn.
      2. It has complicated the access level rules with Inner types as
      mentioned in the *Complications with private types* section of the
      proposal.
      3. I have seen many people (twitter, work, slack) be confused about
      the difference between *private* and *fileprivate* at the global
      level. The answer is none, which shows that both modifiers are not very
      orthogonal.
      4. Since release, I saw people prefer one over the other, as a
      matter of style. They tend to always use *fileprivate* or always
      using *private*. In the latter case, functions and properties get
      clumped in the same class scope instead of be written through multiple
      extensions.
      2. I have the impression that the motivations for the proposal are
   much less real in practice:
   1. The first motivation stated is: *"It is not clear whether the
      implementation details are meant to be completely hidden or can be shared
      with some related code without the danger of misusing the APIs marked as
      private.”* I’ve found that to be fairly rare in practice because
      the implementation details only used to leak inside the same file, which
      greatly reduces the dangers.
      2. The second motivation stated is: *"It forces a one class per
      file structure, which is very limiting." *First of all, this is
      partly false. I think it forces putting classes which share implementation
      details in the same file, which I don’t think is necessarily a bad thing.

To summarise, it seems that the confusion the proposal brought over
semantics and style are not worth the limited benefits that it brought. I’d
be tempted to backtrack the proposal and re-introduce private as a file
scoped access-level and deprecate fileprivate.

Thoughts?
David.

I agree. The minor benefit that fileprivate brings is not worth the
cognitive overhead it introduces. We should just admit it was a mistake and
back it out. We can avoid source-breaking changes by making fileprivate a
synonym for private and provide fixits/warnings for a release to give
people a chance to move off it.

Russ

*_______________________________________________*
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

Comments inline:

I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

Beyond the textual change of using a different modifier name, I don’t see how the encapsulation and organization of code could be affected. Really, there’s not much point in rehashing prior discussion of SE-0025 unless there’s a previously unconsidered angle.

I strongly agree with this sentiment. SE-0025 was very heavily discussed, and while many people were not satisfied with the solution we went with (including me!), it was what the core team and community converged on. I don't expect us to change access control again until and unless we decide to change the model in some way, and even then I think we'll want to go through extra effort to maintain compatibility with Swift 3. As has been mentioned repeatedly, the bar for source-breaking changes is much higher than it was in the first few months of swift-evolution.

I actually consider it very lucky that most of our changes so far have been fairly non-controversial.

I agree. But I think this one is different, and that's why I brought it up :)

Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.

For me, this is not a question of people being unhappy. I've seen create confusion to both old and new Swift developers.

···

On 8 Oct 2016, at 00:56, Jordan Rose via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution <swift-evolution@swift.org> wrote:
On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution <swift-evolution@swift.org> wrote:

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

Strong agreement here as well. This proposal has been litigated numerous times already, and the bar for source-breaking changes is much higher now. To effectively re-open the discussion would require a proposal that significant changes the model with a lot of evidence that such a new model is a drastic improvement over what we have now. “Back out SE-0025” is not a viable option now.

  - Doug

···

On Oct 7, 2016, at 3:56 PM, Jordan Rose via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me <mailto:zach@waldowski.me>

Beyond the textual change of using a different modifier name, I don’t see how the encapsulation and organization of code could be affected. Really, there’s not much point in rehashing prior discussion of SE-0025 unless there’s a previously unconsidered angle.

I strongly agree with this sentiment. SE-0025 was very heavily discussed, and while many people were not satisfied with the solution we went with (including me!), it was what the core team and community converged on. I don't expect us to change access control again until and unless we decide to change the model in some way, and even then I think we'll want to go through extra effort to maintain compatibility with Swift 3. As has been mentioned repeatedly, the bar for source-breaking changes is much higher than it was in the first few months of swift-evolution.

I actually consider it very lucky that most of our changes so far have been fairly non-controversial. Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.

I've migrated multiple projects, both for my own use and for clients.
I've taught Swift 3 to my colleagues as we upgrade, and have to help
seasoned developers through confusion. I've taught Swift 3 to people who
don't know Swift, and have to help novice developers through confusion.
I watch as other developers fight this, such as on Twitter, while
fileprivate is a joke unto its own. That's hardly theoretical.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

···

On Fri, Oct 7, 2016, at 02:08 PM, Shawn Erickson via swift-evolution wrote:

Also based on what do we really see an issue with the addition of
fileprivate? It seems more theory then examples of problems in the
discussions I have seen.

Private access that limits exposure to extensions and subclasses is
the bane of reusability. It sucks in Java and it sucks in Swift. As
far as I know Ruby is the only language that seems to get that.

Agreed. Reading this thread, almost everyone’s presented actual use cases would be fixed if we could do something functionally equivalent to private(type) (even if that’s not the best syntax). If we could have the ability to write extensions for a type throughout a module and access its private properties (and private subtypes, methods, etc.), then the ugliness introduced by fileprivate would be all but eliminated. That’s an access level I would love.

I do want to mention, though, that while I would enjoy C++-style type-level private, I don’t want protected. The rationale for avoiding that in Swift is fantastic.

···

On Oct 7, 2016, at 5:46 PM, Trans via swift-evolution <swift-evolution@swift.org> wrote:

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

I do see dislike of the name, I get that, I among others pushed for
alternate naming (kinda preferred keeping "private" at file scope).

What isn't clear to me is - at least for some - folks asking to remove it
what they actually mean... or what confusion actually exists other then
being something new / different then the past. I prefer to not rush to
quickly to remove something because of noise early in the adoption /
availability of Swift 3.

It seems like some folks may not realize the the old "private" basically
changed its name to "fileprivate" without any behavior change in its
"protection" scope. So when voting to remove fileprivate do they want to
lose file scoping as well or are they asking for the new private to change
back to be file scope (e.g. lose the new private scoping). I also have seen
some of the "mocking" of this feature being based on assuming that file
scope was added and serves no purpose when in fact we always had file
private scoping.

-Shawn

···

On Fri, Oct 7, 2016 at 2:17 PM Zach Waldowski via swift-evolution < swift-evolution@swift.org> wrote:

On Fri, Oct 7, 2016, at 02:08 PM, Shawn Erickson via swift-evolution wrote:

Also based on what do we really see an issue with the addition of
fileprivate? It seems more theory then examples of problems in the
discussions I have seen.

I've migrated multiple projects, both for my own use and for clients. I've
taught Swift 3 to my colleagues as we upgrade, and have to help seasoned
developers through confusion. I've taught Swift 3 to people who don't know
Swift, and have to help novice developers through confusion. I watch as
other developers fight this, such as on Twitter, while fileprivate is a
joke unto its own. That's hardly theoretical.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

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

+1 for me.

I see a little benefit for teams that have multiple people working on a single file (not necessarily at the same time) where a case can be made for a distinction between fileprivate and private. Other than that there is imo no benefit. So to me the question is “is the benefit to those teams worth the burden on the rest of us”?

I honestly do not know the answer to that.

Personally I come down on the side of reverting this change.

Btw: I was not present during the original discussion. If I had been I would have tried to make a case for a “friends list”. In which each scope could have a list of “friends” that have “private” access. This has the advantage that all external access to the scope would be documentation in that scope, and it would open up the possibility of granting private access to closures outside the file the scope was defined in. (private would then become class-private and fileprivate could be eliminated)

Rien.

···

On 07 Oct 2016, at 23:44, Tony Allevato via swift-evolution <swift-evolution@swift.org> wrote:

I actually feel exactly the opposite of this—personally I thought `private` was fine the way it was when it meant `fileprivate` and I had no real need for `private` as it exists in Swift 3.

`fileprivate` is useful because it lets me organize my code in such a way that I divide large types (for example, those that conform to many delegates/other protocols) into multiple extensions in the same file. Any state or helpers that I want to keep in the main class can be defined as `fileprivate` and still be accessible throughout that file, without leaking them into the rest of my module if they were defined as `internal`.

On the other hand, `private` would mostly just protect me from myself at a very small level. In all the Swift code that I've written (this is my anecdotal experience, of course, and I know others differ), it's rare that I've found a strong reason to or benefit from locking something down as `private` instead of `fileprivate`.

Of course, one could argue that `fileprivate` is also protecting me from myself, just a file-based level instead of a scope-based level, but I think it would be more harmful to encourage leaking abstractions out of a file and into a module than it would to leak them out of a scope and into a single file. The affected surface area is much smaller in the latter case.

One possible compromise that pops into my head would be to let `private` not apply to a scope but to a type and also to only those extensions on that type that are visible in the same file—that may have already been discussed during the review of the original proposal. I don't know what the complexity of it would be.

Either way, I would be strongly against anything that removes `fileprivate`. I don't find much use for `private` and nobody is forcing me to use it, so I don't. On the other hand, removing `fileprivate` would prevent a design and code organization pattern that I enjoy about Swift.

On Fri, Oct 7, 2016 at 2:06 PM Zach Waldowski via swift-evolution <swift-evolution@swift.org> wrote:
I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me

On Fri, Oct 7, 2016, at 01:55 PM, Russ Bishop via swift-evolution wrote:

On Oct 7, 2016, at 9:13 AM, David Hart via swift-evolution <swift-evolution@swift.org> wrote:

I started the topic, but I also believe like you that the fileprivate vs private(file) discussion has already been thoroughly discussed and nothing new has been brought up. That’s not what I want to discuss.

I instead want to share my experience using private and fileprivate since release. Here are my thoughts:

  • We should start with the premise that the proposal has added a substantial amount of complexity:
    • It has added an extra modifier and access level to learn.
    • It has complicated the access level rules with Inner types as mentioned in the Complications with private types section of the proposal.
    • I have seen many people (twitter, work, slack) be confused about the difference between private and fileprivate at the global level. The answer is none, which shows that both modifiers are not very orthogonal.
    • Since release, I saw people prefer one over the other, as a matter of style. They tend to always use fileprivate or always using private. In the latter case, functions and properties get clumped in the same class scope instead of be written through multiple extensions.
  • I have the impression that the motivations for the proposal are much less real in practice:
    • The first motivation stated is: "It is not clear whether the implementation details are meant to be completely hidden or can be shared with some related code without the danger of misusing the APIs marked as private.” I’ve found that to be fairly rare in practice because the implementation details only used to leak inside the same file, which greatly reduces the dangers.
    • The second motivation stated is: "It forces a one class per file structure, which is very limiting." First of all, this is partly false. I think it forces putting classes which share implementation details in the same file, which I don’t think is necessarily a bad thing.

To summarise, it seems that the confusion the proposal brought over semantics and style are not worth the limited benefits that it brought. I’d be tempted to backtrack the proposal and re-introduce private as a file scoped access-level and deprecate fileprivate.

Thoughts?
David.

I agree. The minor benefit that fileprivate brings is not worth the cognitive overhead it introduces. We should just admit it was a mistake and back it out. We can avoid source-breaking changes by making fileprivate a synonym for private and provide fixits/warnings for a release to give people a chance to move off it.

Russ

_______________________________________________
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

I have to agree with this; I wasn't especially comfortable with the change (or the eventual choice of keyword style) and in practice I just don't find it useful. I haven't used the new "private" even once since it was added, except by accident, the only form of private I use is fileprivate.

I've happily embraced the conform through extension style in Swift, and really when it comes down to it the new private access level just isn't compatible with that style of development. It's only really useful for hiding details of something you add in one specific section, which I almost never do (and when I do I just mark it fileprivate in case I can re-use it).

Maybe some people do find it useful, but I'd prefer fileprivate to be the default behaviour of private; the current (scoped?) private access level seems far more limited, thus more deserving of a less convenient keyword, or some kind of modifier on private. But personally I'd be fine with removing it, as I don't think it really adds anything that fileprivate doesn't already cover.

···

On 7 Oct 2016, at 22:44, Tony Allevato via swift-evolution <swift-evolution@swift.org> wrote:
personally I thought `private` was fine the way it was when it meant `fileprivate` and I had no real need for `private` as it exists in Swift 3.

Unfortunately, my agreement may come off a bit backhanded. IMHO, the “fileprivate” problem is due to SE-0025 trying to add sophistication to access control too fast.

My observation is that Swift developers as a whole really have not yet come to a conclusion that the permissions already present in the language were truly insufficient for large scale software development. More so, *how* they are insufficient wasn’t clearly represented - for instance, I’ve heard complaints that files become too large by having to bundle dependent extensions and classes, but SE-0025 did little to target their desire for a more manageable codebase. Instead, it allows them to make sections of those large files “more private”.

I’m convinced as the Swift language and other Swift-based projects both gain more maturity, we will be able to get a holistic view of how access control should work and how it should correlate to project structure. Before then, any change may simply do more harm than good.

-DW

···

On Oct 10, 2016, at 10:59 AM, Douglas Gregor via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 3:56 PM, Jordan Rose via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Beyond the textual change of using a different modifier name, I don’t see how the encapsulation and organization of code could be affected. Really, there’s not much point in rehashing prior discussion of SE-0025 unless there’s a previously unconsidered angle.

I strongly agree with this sentiment. SE-0025 was very heavily discussed, and while many people were not satisfied with the solution we went with (including me!), it was what the core team and community converged on. I don't expect us to change access control again until and unless we decide to change the model in some way, and even then I think we'll want to go through extra effort to maintain compatibility with Swift 3. As has been mentioned repeatedly, the bar for source-breaking changes is much higher than it was in the first few months of swift-evolution.

I actually consider it very lucky that most of our changes so far have been fairly non-controversial. Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.

Strong agreement here as well. This proposal has been litigated numerous times already, and the bar for source-breaking changes is much higher now. To effectively re-open the discussion would require a proposal that significant changes the model with a lot of evidence that such a new model is a drastic improvement over what we have now. “Back out SE-0025” is not a viable option now.

  - Doug

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

Not really. This proposal could be backed out without source-breaking changes by treating private as a synonym for fileprivate and we’d have Swift 2 behavior without breaking source. If the core team doesn’t want to consider that then we can just move on and live with it.

Everyone needs to disagree and commit at one time or another. It just irks me because it’s so ugly :)

Russ

···

On Oct 10, 2016, at 9:59 AM, Douglas Gregor via swift-evolution <swift-evolution@swift.org> wrote:

On Oct 7, 2016, at 3:56 PM, Jordan Rose via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Oct 7, 2016, at 15:15, William Sumner via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

On Oct 7, 2016, at 3:05 PM, Zach Waldowski via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I third this sentiment. fileprivate is a nice idea and very clearly has its uses (which is why the proposal got traction in the first place), but when combined with the other access levels, the language feature as a whole feels arbitrary. In practical use, files that I felt were nicely encapsulated and hiding implementation details are now a scattered mix of access levels, adding cognitive load and making the code look unorganized for having the gall to use extensions to split up functionality.

Sincerely,
  Zachary Waldowski
  zach@waldowski.me <mailto:zach@waldowski.me>

Beyond the textual change of using a different modifier name, I don’t see how the encapsulation and organization of code could be affected. Really, there’s not much point in rehashing prior discussion of SE-0025 unless there’s a previously unconsidered angle.

I strongly agree with this sentiment. SE-0025 was very heavily discussed, and while many people were not satisfied with the solution we went with (including me!), it was what the core team and community converged on. I don't expect us to change access control again until and unless we decide to change the model in some way, and even then I think we'll want to go through extra effort to maintain compatibility with Swift 3. As has been mentioned repeatedly, the bar for source-breaking changes is much higher than it was in the first few months of swift-evolution.

I actually consider it very lucky that most of our changes so far have been fairly non-controversial. Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.

Strong agreement here as well. This proposal has been litigated numerous times already, and the bar for source-breaking changes is much higher now. To effectively re-open the discussion would require a proposal that significant changes the model with a lot of evidence that such a new model is a drastic improvement over what we have now. “Back out SE-0025” is not a viable option now.

  - Doug

>
>
> Private access that limits exposure to extensions and subclasses is
> the bane of reusability. It sucks in Java and it sucks in Swift. As
> far as I know Ruby is the only language that seems to get that.

Agreed. Reading this thread, almost everyone’s presented actual use cases
would be fixed if we could do something functionally equivalent to
private(type) (even if that’s not the best syntax). If we could have the
ability to write extensions for a type throughout a module and access its
private properties (and private subtypes, methods, etc.), then the ugliness
introduced by fileprivate would be all but eliminated. That’s an access
level I would love.

I do want to mention, though, that while I would enjoy C++-style
type-level private, I don’t want protected. The rationale for avoiding
that in Swift is fantastic.

If I recall correctly, this idea was also put forward during the original
SE-0025 discussions. However, the design we have now was chosen over this
alternative and others. I was one of those people who didn't really like
the new private, didn't like `fileprivate`, and generally felt that
alternative designs (or even the Swift 2 status quo) could be superior.
But, the discussion was had, all of these viewpoints and more were aired
and mulled over, and a consensus was reached. It'd have to be some
startling new insight to justify yet another change for Swift 4.

···

On Fri, Oct 7, 2016 at 8:49 PM, Braeden Profile via swift-evolution < swift-evolution@swift.org> wrote:

> On Oct 7, 2016, at 5:46 PM, Trans via swift-evolution < > swift-evolution@swift.org> wrote:

_______________________________________________
> 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

Sometimes you have multiple types inside a single file (because you want to share some fileprivate stuff but not make it internal), so it’s handy for that.

But you’re right that the syntax is totally ugly. I think access control is actually once of the biggest weak points of Swift - we should have a way for more arbitrary access control, similar to “friend classes” in C++. So then all of your types don’t need to be stuffed inside the same file in order to share semi-private implementation details. “Internal” is scoped to modules, but many people have also expressed the desire for sub-modules or namespaces and often resort to nasty things like caseless enums or empty structs (why nasty? because they don’t really define types - they’re just used for grouping purposes, and we should have a separate construct for that). So then we may need some way for these sub-modules to share some semi-private implementation details, etc…

I would prefer if we could define some kind of access-domain, and you could assign members or types to those domains. We could possibly have some kind of user-defined access-domains, which you could opt-in to in order to see more details about a type (so you could expose it for subclassing purposes, like “protected”, or in any other more arbitrary way).

So it might look something like:

@access-domain TabBarStuff // the domain itself has an access-domain

class TabController {
    var tabs: [Tab]

    access(public) func closeTab(at: Int) { … }
    access(TabBarStuff) func close(tab: Tab) { … }
}

// Another file. Must be in the same module due to access-domain “TabBarStuff”’s visibility

class Tab {
   unowned var controller : TabController access(TabBarStuff)

    func close() { controller.close(tab: self) }
}

In this case, our API design means that in TabController.close(tab:), we will never get a Tab from a different TabController. This is a nice feature to have, but it requires TabController and Tab to share a member which is not visible to other types. Currently, that means we must have types or extensions scattered around in different files to accommodate for access levels.

Karl

···

On 8 Oct 2016, at 11:31, Haravikk via swift-evolution <swift-evolution@swift.org> wrote:

On 7 Oct 2016, at 22:44, Tony Allevato via swift-evolution <swift-evolution@swift.org> wrote:
personally I thought `private` was fine the way it was when it meant `fileprivate` and I had no real need for `private` as it exists in Swift 3.

I have to agree with this; I wasn't especially comfortable with the change (or the eventual choice of keyword style) and in practice I just don't find it useful. I haven't used the new "private" even once since it was added, except by accident, the only form of private I use is fileprivate.

I've happily embraced the conform through extension style in Swift, and really when it comes down to it the new private access level just isn't compatible with that style of development. It's only really useful for hiding details of something you add in one specific section, which I almost never do (and when I do I just mark it fileprivate in case I can re-use it).

Maybe some people do find it useful, but I'd prefer fileprivate to be the default behaviour of private; the current (scoped?) private access level seems far more limited, thus more deserving of a less convenient keyword, or some kind of modifier on private. But personally I'd be fine with removing it, as I don't think it really adds anything that fileprivate doesn't already cover.
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

I would rather consider using a new keyword that could make it clearer
without looking up for description.

New Current
moduleprivate over internal

···

On Sat, Oct 8, 2016 at 2:44 PM, Rien via swift-evolution < swift-evolution@swift.org> wrote:

+1 for me.

I see a little benefit for teams that have multiple people working on a
single file (not necessarily at the same time) where a case can be made for
a distinction between fileprivate and private. Other than that there is imo
no benefit. So to me the question is “is the benefit to those teams worth
the burden on the rest of us”?

I honestly do not know the answer to that.

Personally I come down on the side of reverting this change.

Btw: I was not present during the original discussion. If I had been I
would have tried to make a case for a “friends list”. In which each scope
could have a list of “friends” that have “private” access. This has the
advantage that all external access to the scope would be documentation in
that scope, and it would open up the possibility of granting private access
to closures outside the file the scope was defined in. (private would then
become class-private and fileprivate could be eliminated)

Rien.

> On 07 Oct 2016, at 23:44, Tony Allevato via swift-evolution < > swift-evolution@swift.org> wrote:
>
> I actually feel exactly the opposite of this—personally I thought
`private` was fine the way it was when it meant `fileprivate` and I had no
real need for `private` as it exists in Swift 3.
>
> `fileprivate` is useful because it lets me organize my code in such a
way that I divide large types (for example, those that conform to many
delegates/other protocols) into multiple extensions in the same file. Any
state or helpers that I want to keep in the main class can be defined as
`fileprivate` and still be accessible throughout that file, without leaking
them into the rest of my module if they were defined as `internal`.
>
> On the other hand, `private` would mostly just protect me from myself at
a very small level. In all the Swift code that I've written (this is my
anecdotal experience, of course, and I know others differ), it's rare that
I've found a strong reason to or benefit from locking something down as
`private` instead of `fileprivate`.
>
> Of course, one could argue that `fileprivate` is also protecting me from
myself, just a file-based level instead of a scope-based level, but I think
it would be more harmful to encourage leaking abstractions out of a file
and into a module than it would to leak them out of a scope and into a
single file. The affected surface area is much smaller in the latter case.
>
> One possible compromise that pops into my head would be to let `private`
not apply to a scope but to a type and also to only those extensions on
that type that are visible in the same file—that may have already been
discussed during the review of the original proposal. I don't know what the
complexity of it would be.
>
> Either way, I would be strongly against anything that removes
`fileprivate`. I don't find much use for `private` and nobody is forcing me
to use it, so I don't. On the other hand, removing `fileprivate` would
prevent a design and code organization pattern that I enjoy about Swift.
>
>
>
> On Fri, Oct 7, 2016 at 2:06 PM Zach Waldowski via swift-evolution < > swift-evolution@swift.org> wrote:
> I third this sentiment. fileprivate is a nice idea and very clearly has
its uses (which is why the proposal got traction in the first place), but
when combined with the other access levels, the language feature as a whole
feels arbitrary. In practical use, files that I felt were nicely
encapsulated and hiding implementation details are now a scattered mix of
access levels, adding cognitive load and making the code look unorganized
for having the gall to use extensions to split up functionality.
>
> Sincerely,
> Zachary Waldowski
> zach@waldowski.me
>
>
> On Fri, Oct 7, 2016, at 01:55 PM, Russ Bishop via swift-evolution wrote:
>>
>>> On Oct 7, 2016, at 9:13 AM, David Hart via swift-evolution < > swift-evolution@swift.org> wrote:
>>>
>>> I started the topic, but I also believe like you that the fileprivate
vs private(file) discussion has already been thoroughly discussed and
nothing new has been brought up. That’s not what I want to discuss.
>>>
>>> I instead want to share my experience using private and fileprivate
since release. Here are my thoughts:
>>>
>>> • We should start with the premise that the proposal has added a
substantial amount of complexity:
>>> • It has added an extra modifier and access level to learn.
>>> • It has complicated the access level rules with Inner
types as mentioned in the Complications with private types section of the
proposal.
>>> • I have seen many people (twitter, work, slack) be
confused about the difference between private and fileprivate at the global
level. The answer is none, which shows that both modifiers are not very
orthogonal.
>>> • Since release, I saw people prefer one over the other,
as a matter of style. They tend to always use fileprivate or always using
private. In the latter case, functions and properties get clumped in the
same class scope instead of be written through multiple extensions.
>>> • I have the impression that the motivations for the proposal are
much less real in practice:
>>> • The first motivation stated is: "It is not clear whether
the implementation details are meant to be completely hidden or can be
shared with some related code without the danger of misusing the APIs
marked as private.” I’ve found that to be fairly rare in practice because
the implementation details only used to leak inside the same file, which
greatly reduces the dangers.
>>> • The second motivation stated is: "It forces a one class
per file structure, which is very limiting." First of all, this is partly
false. I think it forces putting classes which share implementation details
in the same file, which I don’t think is necessarily a bad thing.
>>>
>>> To summarise, it seems that the confusion the proposal brought over
semantics and style are not worth the limited benefits that it brought. I’d
be tempted to backtrack the proposal and re-introduce private as a file
scoped access-level and deprecate fileprivate.
>>>
>>> Thoughts?
>>> David.
>>>
>>
>>
>> I agree. The minor benefit that fileprivate brings is not worth the
cognitive overhead it introduces. We should just admit it was a mistake and
back it out. We can avoid source-breaking changes by making fileprivate a
synonym for private and provide fixits/warnings for a release to give
people a chance to move off it.
>>
>>
>>
>> Russ
>>
>> _______________________________________________
>> 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

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

As far as I can see, almost all people, who talk here, agree that private /
fileprivate distinction brought more harm than good. Despite corresponding
proposal being accepted.
I think, it means that current mailing-list system is failing. Let's accept
it, gmane looks and feels ugly by comparison to forums. And using email
limits the number of people involved by an order of magnitude.
What we need is popularization of SE, reaching as many developers as we
can, using simple voting, likes, and so on.

···

2016-10-08 12:31 GMT+03:00 Haravikk via swift-evolution < swift-evolution@swift.org>:

> On 7 Oct 2016, at 22:44, Tony Allevato via swift-evolution < > swift-evolution@swift.org> wrote:
> personally I thought `private` was fine the way it was when it meant
`fileprivate` and I had no real need for `private` as it exists in Swift 3.

I have to agree with this; I wasn't especially comfortable with the change
(or the eventual choice of keyword style) and in practice I just don't find
it useful. I haven't used the new "private" even once since it was added,
except by accident, the only form of private I use is fileprivate.

I've happily embraced the conform through extension style in Swift, and
really when it comes down to it the new private access level just isn't
compatible with that style of development. It's only really useful for
hiding details of something you add in one specific section, which I almost
never do (and when I do I just mark it fileprivate in case I can re-use it).

Maybe some people do find it useful, but I'd prefer fileprivate to be the
default behaviour of private; the current (scoped?) private access level
seems far more limited, thus more deserving of a less convenient keyword,
or some kind of modifier on private. But personally I'd be fine with
removing it, as I don't think it really adds anything that fileprivate
doesn't already cover.

Not speaking for the core team, just MHO:

I agree with Russ here, and with others who have said upthread that the “thing that has changed” is that we are starting to get usage experience with fileprivate vs private. I think we all understand the value of having fewer access control levels, and so if “private” isn’t conceptually pulling its weight, then it is reasonable to consider phasing it out.

That said, there is no specific rush to have this discussion, and I think it is reasonable to put a pretty high burden of proof on someone who wants to drive such a proposal. For example, if we had the discussion in the spring timeframe, we should have a pretty large body of Swift 3 code readily at hand (e.g. SwiftPM packages and other various github repos).

Given that, it should be easy enough to see how widely private is actually being used in practice. If it is very rare, then the argument to ditch it (make it a synonym for fileprivate, and eventually phasing out fileprivate) is strong. If lots of people are using private and only some are using fileprivate, then the discussion is quite different.

-Chris

···

On Oct 12, 2016, at 9:56 PM, Russ Bishop via swift-evolution <swift-evolution@swift.org> wrote:

I actually consider it very lucky that most of our changes so far have been fairly non-controversial. Everybody has a different idea of what would make Swift a better language, and all of us well-meaning. But when those ideas conflict, some group is going to end up unhappy. I'm actually very glad that (a) we haven't had too many of these cases, and (b) even when we have, people have been able to accept it and move on to contributing to the next issue.

Strong agreement here as well. This proposal has been litigated numerous times already, and the bar for source-breaking changes is much higher now. To effectively re-open the discussion would require a proposal that significant changes the model with a lot of evidence that such a new model is a drastic improvement over what we have now. “Back out SE-0025” is not a viable option now.

  - Doug

Not really. This proposal could be backed out without source-breaking changes by treating private as a synonym for fileprivate and we’d have Swift 2 behavior without breaking source. If the core team doesn’t want to consider that then we can just move on and live with it.