[swift-evolution] access control proposal

Matthew Johnson matthew at anandabits.com
Mon Dec 14 08:51:12 CST 2015


> 
> The language shouldn't dictate how to organize code. The existing solution is great for modules and libraries, but it doesn't work well at the level of a specific API.

+1.  One of my favorite things about Swift is much more flexible physical code organization and an established practice of moving away from one file per class and towards placing related code together regardless for various sense of “related”.  

For example, one may choose to place extensions to a number of types adding conformances to the same protocol in a single file.  I imagine physical layout like this is not uncommon in Swift code.  This does not necessarily mean you want these extensions to see implementation details of each other.  By adding a ‘scope’ access modifier we are able to properly hide these implementation details regardless of physical layout.  

This also improves robustness if you later decide to modify the physical organization of your code without changing visibility of the implementation details of the extensions.

Matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20151214/c8163a02/attachment.html>


More information about the swift-evolution mailing list