[swift-evolution] [Pitch] consistent public access modifiers
matthew at anandabits.com
Mon Feb 13 11:33:44 CST 2017
> On Feb 13, 2017, at 11:28 AM, James Froggatt via swift-evolution <swift-evolution at swift.org> wrote:
> Having loosely followed this discussion, the way I'm thinking of ‘closed’ is as a modifier which would let you switch over something from outside the module in which it is declared.
> From outside the declaring module:
> • A closed enum's cases can be exhaustively switched.
> • A closed protocol's conforming types can be exhaustively switched.
> • A closed class's subclasses can be exhaustively switched.
> If this is correct, I can't help but think ‘closed’ is describing something subtly different in each case - picking and choosing the ‘important’ relationship for each type, while protocols already have a subtyping relationship, and it sounds like there's possibility for enum subtyping in the future.
> I'd rather keep ‘open’ (and a potential future ‘closed’) purely describing the subtyping relationship, and have some other means of labelling conformance and cases as switchable.
I am drafting a manifesto-style document regarding value subtyping which will make it clear how value subtypes fit into the picture. This document covers the relationship of enum cases with value subtyping and will show clearly how enum cases are analogous to subclasses.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution