Suggestion to clean up the mess around access modifiers

It’s not meant to be a proposal but a suggestion to all that mess around the access modifiers that is currently going on. You can take the suggestion from here, if you like it, and write a proper proposal. ;)

Formatted version: not-swift-access-modifier.md · GitHub

Suggestion 1 Suggestion 2 Swift 3
public open open
closed public public public
fixed public
final public closed final public
internal internal internal
final internal final internal final internal
private private fileprivate
final private final private final fileprivate
scoped scoped private
open is no more an exclusive access modifier, which shouldn’t exist in the first place, because of the mentioned exclusivity. That’s what attributes are meant for.
Allowing closed public protocols seems straightforward for Suggestion 1.
First suggestion aligns the closed attribute very well with final and its purpose becomes crystal clear.
scoped is a straw_hat_name from the on going discussions, you can replace it with something better.
fixed public is from Matthew’s discussion thread.
Personally I’d go with #1!

···

--
Adrian Zubarev
Sent with Airmail

Updated with a third suggestion which makes it more clear that ‘closed’ by default simply does not work without allowing the existence of closed protocols.

Formated version: Sign in to GitHub · GitHub

Suggestion 1 Suggestion 2 Suggestion 3 Swift 3 Implication of #3
public open open public open open
closed public public public public public
fixed public
final public closed final public final public final public
internal internal internal internal internal
final internal final internal final internal final internal final internal
private private private fileprivate private
final private final private final private final fileprivate final private
scoped scoped scoped private scoped
open is no more an exclusive access modifier, which shouldn’t exist in the first place, because of the mentioned exclusivity. That’s what attributes are meant for.
Allowing closed public protocols seems straightforward for Suggestion 1.
First suggestion aligns the closed attribute very well with final and its purpose becomes crystal clear.
scoped is a straw_hat_name from the on going discussions, you can replace it with something better.
fixed public is from Matthew’s discussion thread.
Third suggestion makes open as an attribute, however this is a breaking change for all other types different form classes, because currently protocols have open semantics, and value types might get subtypes one day, which makes them closed by today’s standards. The default in the first suggestion is alway open, compared to the third suggestion, which is closed.
The implication of the third suggestion is the necessary fix for protocols: open/public protocol (shown in the last row).