[swift-evolution] [Discussion] fileprivate vs. private(file)

Ross O'Brien narrativium+swift at gmail.com
Mon Feb 20 09:25:34 CST 2017

> This is what I had in mind; i.e- you don't *have* to parameterise
> private, you'd only do it if you want something other than the default.
> As for something with both public and private modifiers (only really
> applies to properties I think?) I think it's fine to just declare each
> separately, as there may in future be more public parameters so it makes
> sense to have the separate grouping of a property's public and private
> components.
> I'm not clear on your use of private(type:module), what do you see that as
> representing? Personally I'd just expect them to be used like
> private(module, type), i.e- the method/property is private but accessible
> by both module and (externally) by sub-classes.
Does 'private(module, type)' grant get-set access to external subclasses,
or get-only?

If I write 'private(file, type)' is the property accessible only to types
within the module, or outside as well?

The 'type' axis (which includes the 'protected' concept) is related to the
'module' axis (which includes 'internal' and 'fileprivate') and the 'get
set' axis. Perhaps not strictly orthogonal, but still three dimensions. If
Swift is to add a type axis, we should be careful not to think of it as
simply additional states on the 'module' axis.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170220/69695e7e/attachment-0001.html>

More information about the swift-evolution mailing list