<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 9, 2018 at 10:10 PM, Chris Lattner <span dir="ltr"><<a href="mailto:clattner@nondot.org" target="_blank">clattner@nondot.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On Jan 9, 2018, at 3:07 PM, Jose Cheyo Jimenez <<a href="mailto:cheyo@masters3d.com">cheyo@masters3d.com</a>> wrote:<br>
> Hi Chris,<br>
><br>
> This is great. Thanks for spending time on this! I am in favor of `case #unknown` to only match unknown cases.<br>
><br>
> 1) Would #uknown be available to RawRepresentable structs?<br>
<br>
</span>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.<br>
<br>
What do you have in mind? If your raw representation is itself an enum, then of course this would work.<br></blockquote><div><br></div><div>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. </div><div><br></div><div><div>struct Directions: OptionSet {</div><div> let rawValue: UInt8</div><div> static let up = Directions(rawValue: 1 << 0)</div><div>}</div><div><br></div><div>let myDir = Directions.up</div><div><br></div><div>switch myDir</div><div>{</div><div> case .up : print("matched")</div><div> default: print("default required") </div><div>}</div></div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span class="gmail-"><br>
> 2) How is the #uknown pattern accomplished? Are you suggesting to capture all the compile time known cases so you can do a diff during<br>
> runtime? (Sorry this is not obvious to me)<br>
<br>
</span>The internals of the compiler would handle this, it is difficult to explain unless you know the bowels of silgen and irgen :-)<br>
<span class="gmail-HOEnZb"><font color="#888888"><br>
-Chris<br>
<br>
<br>
</font></span></blockquote></div><br></div></div>