<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><div class="">Hello everyone,&nbsp;</div><div class=""><br class=""></div><div class="">My name is Eneko Alonso, iOS developer, new here on the list.</div><div class=""><br class=""></div><div class="">Is there a good summary anywhere that condenses the pros and cons of this new feature that have been discussed so far?</div><div class=""><br class=""></div><div class="">It is not clear to me why non-exhaustive would be the default, requiring adding `@exhaustive` otherwise. Has anyone discussed doing it the other way around, this is, defaulting to exhaustive (no changes with prior Swift versions) and adding a `@nonExhaustive` tag instead as needed?</div><div class=""><br class=""></div><div class="">Apologies if this has been covered already.</div><div class=""><br class=""></div><div class="">Regards and thank you everyone for making Swift better!</div><div class="">Eneko</div><div class=""><br class=""></div><div><br class=""><blockquote type="cite" class=""><div class="">On Dec 27, 2017, at 10:26 PM, Riley Testut via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""></div><div class="">Actually, from the other email thread about this same topic (thank god forums are almost here), I see the proposed syntax “final switch” for what I referred to as “switch!”, which I prefer.</div><div class=""><br class="">On Dec 28, 2017, at 12:17 AM, Riley Testut via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class=""></div><div class="">-1.</div><div class=""><br class=""></div><div class="">I agree this is a problem, but I think this is the wrong solution. I think the solution should be on the <i class="">client</i> side, not on the framework author’s side.</div><div class=""><br class=""></div><div class="">I would be fine if enums from imported modules are non-exhaustive, as long as I can <i class="">choose</i> to treat them as exhaustive if I want to. And in that case, if a new case is introduced, I think a fatal error is a reasonable result.</div><div class=""><br class=""></div><div class="">The proposed “switch!” command would do just this, and I think that is the better answer for this. Adding an @exhaustive attribute doesn’t actually prevent someone from adding a case anyway, which I think is a big (and not really solvable) issue 🤷‍♂️</div><div class=""><br class=""></div><div class="">I know much has been said about this, but it’s just my 2c.</div><div class=""><br class=""></div><div class="">On Dec 27, 2017, at 9:42 AM, Thorsten Seitz via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" class=""><br class=""><div class=""><br class=""><blockquote type="cite" class=""><div class=""><span style="font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class="">The proposal is available here:</span></div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><blockquote style="-webkit-print-color-adjust: exact; margin: 15px 0px; border-left-width: 4px; border-left-style: solid; border-left-color: rgb(221, 221, 221); padding: 0px 15px; color: rgb(119, 119, 119); font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><div style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><a href="https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0192-non-exhaustive-enums.md</a></div></blockquote><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">What is your evaluation of the proposal?</p></li></ul></div></div></blockquote><div class=""><br class=""></div>-1</div><div class=""><br class=""></div><div class="">I would much prefer the solution proposed by Andrew Bennett in another thread which solves all problems very nicely including the testability of future cases by giving them a placeholder name:</div><div class=""><br class=""></div><div class="">From Andrew’s mail:</div><blockquote type="cite" class=""><div class=""><div style="font-family: HelveticaNeue;" class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">public</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">enum</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-en" style="color: rgb(111, 66, 193); box-sizing: border-box;">HomeworkExcuse</span><font color="#24292e" class=""> {
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c1" style="box-sizing: border-box;"><font color="#0b5394" class="">eatenByPet</font></span><font color="#24292e" class="">
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c1" style="box-sizing: border-box;"><font color="#0b5394" class="">thoughtItWasDueNextWeek</font></span><font color="#24292e" class="">
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">fallback </span><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="box-sizing: border-box;"><font color="#0b5394" class="">unknown</font></span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c" style="color: rgb(106, 115, 125); box-sizing: border-box;"><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c" style="box-sizing: border-box;">//</span> NEW</span><font color="#24292e" class="">
</font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c" style="box-sizing: border-box; color: rgb(106, 115, 125);"></span><font color="#24292e" class="">}</font></pre></div><div style="font-family: HelveticaNeue;" class=""><br class=""></div><div style="font-family: HelveticaNeue;" class="">Then I believe you would be able to have an exhaustive switch like this:</div><div style="font-family: HelveticaNeue;" class=""><br class=""></div><div style="font-family: HelveticaNeue;" class=""><pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, &quot;Liberation Mono&quot;, Menlo, Courier, monospace; font-size: 13.600000381469727px; margin-top: 0px; margin-bottom: 0px; word-wrap: normal; padding: 16px; overflow: auto; line-height: 1.45; background-color: rgb(246, 248, 250); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px; word-break: normal;" class=""><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-en" style="box-sizing: border-box;"><font color="#d73a49" class="">switch </font></span><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-en" style="color: rgb(111, 66, 193); box-sizing: border-box;">thing</span><font color="#24292e" class=""> {
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c1" style="box-sizing: border-box;"><font color="#0b5394" class="">eatenByPet: </font><font color="#cc0000" class="">break</font></span><font color="#24292e" class="">
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">case</span><font color="#24292e" class=""> </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c1" style="box-sizing: border-box;"><font color="#0b5394" class="">thoughtItWasDueNextWeek:</font><font color="#cc0000" class=""> break</font></span><font color="#24292e" class="">
  </font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="color: rgb(215, 58, 73); box-sizing: border-box;">case </span><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-k" style="box-sizing: border-box;"><font color="#0b5394" class="">unknown</font><font color="#24292e" class="">: </font><font color="#cc0000" class="">break</font></span><font color="#24292e" class="">
</font><span class="gmail-m_1118565368265080773gmail-m_-1318432576890994713gmail-pl-c" style="box-sizing: border-box; color: rgb(106, 115, 125);"></span><font color="#24292e" class="">}</font></pre></div><div style="font-family: HelveticaNeue;" class=""><br class=""></div><div class="gmail_extra" style="font-family: HelveticaNeue;">Which would&nbsp;<b class="">still allow compile-time errors if new cases are introduced</b>, while providing a concise way to show something is not exhaustible.</div><div class="gmail_extra" style="font-family: HelveticaNeue;"><br class=""></div><div class="gmail_extra" style="font-family: HelveticaNeue;">This would also&nbsp;<b class="">support existing enums with "unknown" equivalent cases</b>&nbsp;would be able to explicitly label those fields as&nbsp;fallback without needing to make large code changes.</div><div class="gmail_extra" style="font-family: HelveticaNeue;"><br class=""></div><div class="gmail_extra" style="font-family: HelveticaNeue;">I see no reason why you shouldn't be able to use ".unknown", which&nbsp;<b class="">should still allow this to be testable</b>.</div></div></blockquote><div class=""><div class=""><br class=""></div><div class="">i.e. Andrew’s idea is to introduce a placeholder case instead of marking the enum as exhaustive/non-exhaustive. This gives the future cases a handle to be switched on and to be tested against. Very elegant.</div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">Is the problem being addressed significant enough to warrant a change to Swift?</p></li></ul></div></div></blockquote>Yes, but the proposed solution is not as good as it should be, neglecting to provide compile-time errors if new cases are introduced.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">Does this proposal fit well with the feel and direction of Swift?</p></li></ul></div></div></blockquote>No, due to its shortcomings.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</p></li></ul></div></div></blockquote>None, but see Andrew Bennett’s idea above.<br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class=""><ul style="-webkit-print-color-adjust: exact; margin: 15px 0px; padding-left: 30px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);" class=""><li style="-webkit-print-color-adjust: exact; margin: 0px;" class=""><p style="-webkit-print-color-adjust: exact; margin: 0px 0px 15px;" class="">How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</p></li></ul></div></div></blockquote>Followed most of the discussion and review threads.</div><div class=""><br class=""></div><div class="">-Thorsten</div></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-evolution mailing list</span><br class=""><span class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br class=""></div></blockquote></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>