[swift-evolution] Simplifying Access Using 'Hidden'

Joanna Carter joanna at carterconsulting.org.uk
Wed Feb 15 15:49:15 CST 2017


> 
> Here's an idea in three points:
> 
> 1. Return to the Swift 2 definition of `private`.
> 2. Introduce `scoped` to limit the visibility to within the same type, subtype, or extension.
> 3. Allow mixing the two.
> 
> So you have:
> 
> 	private         // current file
> 	private scoped  // current file, in the same type, subtype, or ext.
> 	internal        // current module
> 	internal scoped // current module, in the same type, subtype, or ext.
> 	public          // external modules
> 	public scoped   // maybe we want that one?
> 
> Since `internal` is implied, using `scoped` alone would be equivalent to `internal scoped`.
> 
> Swift 3's private could be mapped to `private scoped` to achieve (almost) the same results and thus preserve source compatibility.

Without wishing to offend, this seems to be creating a lot more keywords for people to try and get their heads around. I am a firm believer in KISS and would like to see the bare minimum of keywords for scopes, so as not to confuse the elderly, frail, young, inexperienced, etc ;-)

--
Joanna Carter
Carter Consulting



More information about the swift-evolution mailing list