[swift-evolution] Type-based ‘private’ access within a file

Brent Royal-Gordon brent at architechies.com
Mon Apr 3 16:59:56 CDT 2017

> On Apr 3, 2017, at 2:54 PM, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
> Moreover, I think that we need *additional* access level(to current 'private'), which will mean 'can be accessed from extensions and subtypes in the same *module*' to be able to split type's conformances to number of files and don't make implementation details accessible&visible for whole module. (there was 'extensible' modifier discussed previously).

If we wanted to do this, I think we'd want a `protected` modifier that was orthogonal to `internal` and `private` (which would probably revert to `fileprivate` semantics):

	struct Foo {
		private let bar: Int			// Only visible in this file
		protected private let baz: Int	// Only visible in this file and type
		let quux: Int				// Only visible in this module
		protected let quuux: Int		// Only visible in this module and type

We might then consider extending `protected` to `public` and `open` scope.

I mention this not because I think type-based scoping is a good idea, but because if we're gonna do it, we shouldn't do it halfway.

Brent Royal-Gordon

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170403/50b90e5e/attachment.html>

More information about the swift-evolution mailing list