You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 26, 2023. It is now read-only.
Copy file name to clipboardExpand all lines: _drafts/2017-04-06-issue-64.md
+38-11Lines changed: 38 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ sponsor:
8
8
body: Dave Verwer from iOS Dev Weekly here. I'm a big fan of the Swift Weekly Brief so when I saw they were looking for support, I thought I should do that! Keep up the good work Jesse!
9
9
---
10
10
11
-
> TODO: intro comments
11
+
The great access control ~~battle~~ debate is finally over! Yet, the ~~holy war~~ discussion is not quite over.
12
12
13
13
<!--excerpt-->
14
14
@@ -30,17 +30,22 @@ Speaking of JP Simard, he released [SourceKitten 0.17.1](https://github.com/jpsi
30
30
31
31
> TODO
32
32
33
-
### Accepted proposals
34
-
35
-
> TODO
36
-
37
-
### Returned proposals
38
-
39
-
> TODO
40
-
41
33
### Rejected proposals
42
34
43
-
> TODO
35
+
[SE-0159](https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md): *Fix Private Access Levels* was [rejected](https://lists.swift.org/pipermail/swift-evolution-announce/2017-April/000337.html).
36
+
37
+
> The core team had a lengthy discussion of this proposal as well as related ideas that came up during (and prior to) the review.
38
+
>
39
+
> [SE-0159](https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md) specifically sought to revert the main user-facing part of [SE-0025](https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md), which gave `private` lexical-scoping semantics and introduced `fileprivate`. The core team felt that there was sufficient evidence that more-restrictive-than-fileprivate access control is in use within the Swift community and in established patterns, such that it would be harmful to remove the functionality introduced by [SE-0025](https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md) at this point.
40
+
>
41
+
> The core team discussed the idea of renaming to keywords that was brought up in the thread as a way to address many of the concerns raised in [SE-0159](https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md) while providing the same language semantics. Specifically:
42
+
>
43
+
> *`private` -> `scoped`
44
+
> *`fileprivate` -> `private`
45
+
>
46
+
> The core team determined that such a change, while (technically) easy to automatically migrate, would introduce far too much churn in Swift code bases moving from Swift 3 to Swift 4, compromising the source stability goals set out for Swift 4.
47
+
>
48
+
> Finally, the core team discussed a different potential design for “private” that admits a limited form of type-based access control within files. We will open a separate discussion thread on Swift Evolution, with the subject "Type-based 'private' access within a file", and are seeking further discussion there and a motivated volunteer to turn it into a new proposal for Swift 4.
44
49
45
50
### Proposals in review
46
51
@@ -72,7 +77,29 @@ Speaking of JP Simard, he released [SourceKitten 0.17.1](https://github.com/jpsi
72
77
73
78
### Mailing lists
74
79
75
-
> TODO
80
+
As mentioned above in the rejection of SE-0159, Doug Gregor has [opened a new discussion](https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170403/034903.html) about implementing type-based 'private' access within a file — which will hopefully settle Swift's access control story for good.
81
+
82
+
> In rejecting [SE-0159](https://github.com/apple/swift-evolution/blob/master/proposals/0159-fix-private-access-levels.md), the core team described a potential direction we would like to investigate for “private” access control that admits a limited form of type-based access control within files. The core team is seeking some discussion here and a motivated volunteer to put together a proposal along these lines for review in the Swift 4 time-frame (i.e., very soon). To be clear, the core team isn't sure this is the right direction to go... but it appears promising and we would *love* to be able to settle the access-control issue.
83
+
>
84
+
> The design, specifically, is that a “private” member declared within a type “X” or an extension thereof would be accessible from:
85
+
>
86
+
> * An extension of “X” in the same file
87
+
> * The definition of “X”, if it occurs in the same file
88
+
> * A nested type (or extension thereof) of one of the above that occurs in the same file
89
+
>
90
+
> This design has a number of apparent benefits:
91
+
> *`private` becomes the right default for "less than whole module" visibility, and aligns well with Swift coding style that divides a type’s definition into a number of extensions.
92
+
> *`fileprivate` remains for existing use cases, but now it’s use it more rare, which has several advantages:
93
+
> * It fits well with the "progressive disclosure" philosophy behind Swift: you can use `public`/`internal`/`private` for a while before encountering and having to learn about `fileprivate` (note: we thought this was going to be true of [SE-0025](https://github.com/apple/swift-evolution/blob/master/proposals/0025-scoped-access-level.md), but we were clearly wrong)
94
+
> * When `fileprivate` occurs, it means there’s some interesting coupling between different types in the same file. That makes `fileprivate` a useful alert to the reader rather than, potentially, something that we routinely use and overlook so that we can separate implementations into extensions.
95
+
> *`private` is more closely aligned with other programming languages that use type-based access control, which can help programmers just coming to Swift. When they reach for `private`, they’re likely to get something similar to what they expect—with a little Swift twist due to Swift’s heavy use of extensions.
96
+
> * Loosening the access restrictions on `private` is unlikely to break existing code.
97
+
>
98
+
> There are likely some drawbacks:
99
+
> * Developers using patterns that depend on the existing lexically-scoped access control of `private` may find this new interpretation of `private` to be insufficiently strict
100
+
> * Swift’s access control would go from "entirely lexical" to "partly lexical and partly type-based", which can be viewed as being more complicated
0 commit comments