[swift-evolution] access control proposal

Matthew Johnson matthew at anandabits.com
Sun Dec 13 17:53:09 CST 2015


>> I don’t think these are troll proposals. They *are* a little more limited, a little more esoteric, but you could say the same thing about `local` vs. `private`. And in some cases you can emulate some of these with the four access modifiers you want, but again, you could say the same thing about `local` vs. `private`.
> 
> You're right.  Your examples have convinced me of this point.  There exist non-troll proposals for further access modifiers.

There are definitely further refinements to access control that could be desired.  I have given them some thought as this thread has proceeded.  There would be ways to accommodate them through refinement of the 'scope' access level.  

For example, we could allow a syntactic 'scope {}' block which would be transparent for all purposes except introducing a scope for access control.  We could also allow labeled scopes and allow the 'scope' access control level to specify a label, for example to allow an inner type to expose scoped members to the outer type but not other code in the same file.

While this potential exists I think it introduces complexity that is probably not worth it.  I am only mentioning these ideas to demonstrate that a 'scope' access modifier is something that can be refined to provide more control if enough compelling use cases were identified.  We wouldn't need to add entirely new access modifiers to address such use cases.

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


More information about the swift-evolution mailing list