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

Matthew Johnson matthew at anandabits.com
Fri Apr 7 10:23:40 CDT 2017

> On Apr 7, 2017, at 10:06 AM, BJ Homer via swift-evolution <swift-evolution at swift.org> wrote:
>> It does not remove the scoped access control, it only relaxes it in extensions to types in the same file.
> Many of the use cases for scoped access given during the review of SE-0159 specifically related to restricting access between extensions in the same file. I don't personally use this, but it seems it is definitely used by some developers. 

The most common thing is to have some stored properties that are private and include a handful of fileprivate (or higher) methods that operate on these properties in the type declaration.  All members that don’t need direct access to these properties are placed in extensions specifically to prevent the direct access to stored properties which they don’t need.  This minimizes the lines of code with access to such properties.

> -BJ
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170407/1883c89e/attachment.html>

More information about the swift-evolution mailing list