<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><div><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">On 24/12/2017, at 9:40 AM, Cheyo Jimenez via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></span></font></div><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);"><br>What are your thoughts on `final switch` as a way to treat any enum as exhaustible?</span></font><div><a href="https://dlang.org/spec/statement.html#FinalSwitchStatement" style="background-color: rgba(255, 255, 255, 0);"><font color="#000000">https://dlang.org/spec/statement.html#FinalSwitchStatement</font></a></div></blockquote><blockquote type="cite"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span></font></blockquote></div><span style="background-color: rgba(255, 255, 255, 0);"><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div>I’d be very much in favour of this (qualms about the naming of the ‘final’ keyword aside - ‘complete’ or ‘exhaustive’ reads better to me). </span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">Looking back at the proposal, I noticed that something similar was mentioned that I earlier missed. In the proposal, it says:</span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><blockquote type="cite" preoffsettop="179"><font color="#000000"><span style="background-color: rgba(255, 255, 255, 0);">However, this results in some of your code being <em style="box-sizing: border-box;">impossible to test,</em> since you can't write a test that passes an unknown value to this switch.<br></span></font></blockquote><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><span style="background-color: rgba(255, 255, 255, 0);">Is that strictly true? Would it be theoretically possible for the compiler to emit or make accessible a special ‘test’ case for non-exhaustive enums that can only be used in test modules or e.g. by a ‘EnumName(testCaseNamed:)’, constructor? There <i>is</i> potential for abuse there but it <i>would </i>address that particular issue. </span></div><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div><span style="background-color: rgba(255, 255, 255, 0);">Regardless, I still feel something like a ‘final switch’ is necessary if this proposal is introduced, and that it fits with the ‘progressive disclosure’ notion; once you learn this keyword you have a means to check for completeness, but people unaware of it could just use a ‘default’ case as per usual and not be concerned with exhaustiveness checking. <br></span><div><span style="background-color: rgba(255, 255, 255, 0);"><br></span><div><span style="background-color: rgba(255, 255, 255, 0);">Thomas</span></div></div></div><div><br></div></div></body></html>