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

Nevin Brackett-Rozinsky nevin.brackettrozinsky at gmail.com
Tue Apr 4 21:25:38 CDT 2017


On Tue, Apr 4, 2017 at 10:00 PM, Brent Royal-Gordon <brent at architechies.com>
wrote:

>
> There *may* be gains to be made by a ` `private` -> `scoped`/`fileprivate`
> -> `private` switch (I'm skeptical, but I can see the argument), but that's
> not in the offing, either.
>

For myself (and I suspect for many others) the file scope is exactly the
visibility level I want, at least until we get submodules. When I put
multiple types or extensions in the same file, it is precisely because I
want them to be able to work together at a low level. Even in a simple file
that just has one type and no extensions, I still want the file scope so
that in the future if I ever need to add other things to the file, it will
all just work without having to change access levels.

So under the current scheme, I end up writing “fileprivate” everywhere and
“private” nowhere. This gives the semantics I want, but it is absurdly
ugly. My only other option is to go full Pestov and make everything
“internal”, which is beautiful in its syntactic minimalism but doesn’t
achieve encapsulation.

SE-0025 took what I see as the basic, preferred, desirable access level and
made it for all appearances into a second-class citizen of the language.
Switching the spellings would fix that.

Nevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170404/1e11f859/attachment.html>


More information about the swift-evolution mailing list