[swift-evolution] [Discussion] A Problem With SE-0025?

Brent Royal-Gordon brent at architechies.com
Thu Jun 16 05:20:03 CDT 2016


> 6. With the core team tied up at WWDC, you may want to temporarily forbid the use of `private` on a type and revisit the matter when people are less busy; if necessary, we could even ship Swift 3 that way. Or you may want to consider making a guess as to a good implementation model to apply. Two suggestions for alternate implementation models:
> 
> a. Introduce a `parent` access level, meaning "visible in scopes within this file where the parent is visible", which is between `fileprivate` and `private`. Just as `internal` is the maximum inherited access level, `parent` is the minimum, so the members of a `private` type would inherit `parent` visibility. `parent` might be an entirely compiler-internal concept, with no utterable access control keyword.

Thinking about this more, I notice that `fileprivate` as currently defined doesn't actually make any sense to say inside a `private` type: if your parent type has less-than-file-wide visibility, nothing in the file that's outside its scope can see you anyway. Therefore, we could redefine `fileprivate` thusly:

	1. A member with `fileprivate` visibility is visible within the scope in which the nearest containing `private` type is visible.
	2. If there are no containing `private` types, it is visible within the file containing it.
	3. Just as the members of a `public` type are `internal`, so the members of a `private` type are `fileprivate`.

This kind of suggests that we ought to rename `fileprivate` to something that, y'know, doesn't say "file" in it. However, I can scarcely imagine the results of a round of bikeshedding without parental supervision from the core team, so I don't dare make any suggestions.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list