> On Oct 21, 2016, at 12:23 PM, Tony Allevato via swift-evolution 
> <[email protected]> wrote:
> 
> Now there's a caveat here worth discussing: would the intention of an 
> "enum-constrained protocol" be to define the *only* cases it can have, or 
> just the minimal set? The former would let you do some interesting generic 
> protocol-constrained exhaustive pattern matching. However, given that no 
> other use of protocols defines an *exact* set (you don't say these are the 
> *only* methods/properties that a conforming type can implement), I think it 
> would be a hard sell to apply a stronger restriction specifically to enums. 
> In any case, it feels to me like an enum restricted to "only these exact 
> cases" calls more for a generic enum rather than a protocol-based solution.

I would say it should define the minimal set, and any switching over the 
generic protocol type needs either a `default` or a `case _` clause to handle 
concrete types which have more cases than the protocol requires.

- Dave Sweeris
_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to