[swift-evolution] private & fileprivate
swift-evolution at haravikk.me
Fri Oct 7 07:11:57 CDT 2016
> On 7 Oct 2016, at 12:11, Jay Abbott <jay at abbott.me.uk> wrote:
> I agree that the keywords could be improved, but private(file) access should not be what 'private' means by itself. If I put just 'private' in front of something I really mean it should be private to this scope, the most private. I also think the more common use-case would be private(scope) over private(file), you might find if you refactor a bit that a lot of your fileprivate can become private or instead - it's possible that fileprivate is encouraging you to put things into one file when they should be in multiple files with a better defined 'internal' API.
> I like the *concept* that 'private' is the most private and then it can be relaxed by modifiers (file) (module) (perhaps-other-stuff), but I'm not convinced that 'private' is really an appropriate word for something that is accessible anywhere within a module. Though I agree that 'internal' doesn't really mean much to someone learning the language, and suffers the exact same problem (internal to what?) whereas private(module) does express that a bit better.
Yeah I'm a bit undecided on that point myself; like I say I'd really prefer something like private(type) to be the default for my own use-case, but not only do we not have that it probably wouldn't suit everyone anyway, I think it's just more that my habit is to implement by extension within the same file. With that in mind maybe scope is the better default for it as you say.
I'm not sure what the OP really wanted to raise on the subject, but if there's interest for this style of access modifier and it's in-scope for Swift 4 then I could do a proposal for it as a specific request.
More information about the swift-evolution