[swift-evolution] Simplifying Access Using 'Hidden'
razielim at gmail.com
Mon Feb 13 10:35:39 CST 2017
> On 13 Feb 2017, at 17:21, Adrian Zubarev via swift-evolution <swift-evolution at swift.org> wrote:
> People talk always like “I never liked fileprivate” and I feel like some of you forgot that fileprivate is not new to Swift. It’s the repainted private from days before Swift 3. I cannot recall anyone complaining about it that much. There were some people that forced the addition of a stricter private access modifier for Swift 3. Now that we have both, there are a lot of complains about fileprivate.
It _is_ kind of ugly. I would support rearranging our access lives like this, with a parameterised “private”:
private(module) // today’s “internal”
private(file) // today’s “fileprivate”
private // today’s “private”
It also opens the door to more nuanced access levels, such as private(type) to allow access to the hidden member in cross-file extensions but not generally throughout the module.
For properties, it would mean
public internal(set) var something: Bool
public private(module, set) var something: Bool
at which point it might be nicer to flip the arguments and call it “setter”:
public private(setter, module) var something: Bool
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution