> On Jan 10, 2018, at 12:04, Jose Cheyo Jimenez via swift-evolution 
> <[email protected]> wrote:
> 
> 
> 
> On Tue, Jan 9, 2018 at 10:10 PM, Chris Lattner <[email protected] 
> <mailto:[email protected]>> wrote:
> On Jan 9, 2018, at 3:07 PM, Jose Cheyo Jimenez <[email protected] 
> <mailto:[email protected]>> wrote:
> > Hi Chris,
> >
> > This is great. Thanks for spending time on this! I am in favor of `case 
> > #unknown` to only match unknown cases.
> >
> > 1) Would #uknown be available to RawRepresentable structs?
> 
> I haven’t considered this, so I’m not sure how that would work.  I had 
> assumed that this would be an enum specific concept.
> 
> What do you have in mind?  If your raw representation is itself an enum, then 
> of course this would work.
> 
> I was just curious since a RawRepresentable structs ( and OptionSet ) are 
> very similar to non exhaustive enums in that they would require handling 
> unknown cases. Currently RawRepresentable is required to use a default even 
> if all cases are accounted for. 
> 
> struct Directions: OptionSet {
>     let rawValue: UInt8
>     static let up    = Directions(rawValue: 1 << 0)
> }
> 
> let myDir = Directions.up
> 
> switch myDir
> {
>     case .up : print("matched")
>     default: print("default required") 
> }

Since an option set has 2^N possible values, not just N, we don't expect anyone 
to be switching over them! And it wouldn't be correct to try to do so 
exhaustively anyway.

Jordan

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

Reply via email to