<html><body><div id="zimbraEditorContainer" style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000" class="37"><div><br></div><div><br></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>De: </b>"Brian Goetz" <brian.goetz@oracle.com><br><b>À: </b>"amber-spec-experts" <amber-spec-experts@openjdk.java.net><br><b>Envoyé: </b>Lundi 31 Août 2020 15:25:13<br><b>Objet: </b>Re: [pattern-switch] Opting into totality<br></blockquote></div><div data-marker="__QUOTED_TEXT__"><blockquote style="border-left:2px solid #1010FF;margin-left:5px;padding-left:5px;color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;">I think this is the main open question at this point.  <div class=""><br class=""></div><div class="">We now have a deeper understanding of what this means, and the shape of the remainder.  Totality means not only â€œspot check me that I’m right”, but also â€œI know there might be some remainder, please deal with it.”   So totality is not merely about type checking, but about affirmative handling of the remainder.  </div><div class=""><br class=""></div><div class="">Expression switches automatically get  this treatment, and opting _out_ of that makes no sense for expression switches (expressions must be total), but statement switches make sense both ways (just like unbalanced and balanced if-else.)  Unfortunately the default has to be partial,  so the main question is, how  do we indicate the desire for totality in a way that is properly evocative for the user?  </div><div class=""><br class=""></div><div class="">We’ve talked about modifying switch (sealed switch), a hyphenated keyword (total-switch), a trailing modifier (switch case), and synthetic cases (“default: unreachable”).  Of course at this point it’s â€œjust syntax”, but I think our goal should be picking something that  makes it obvious to users that what’s going on is not merely an assertion of totality, but also a desire to handle the remainder.  <br class=""><div><br class=""><blockquote class=""><div class=""><span style="font-family: monospace; font-size: large;" class="">   - How does a switch opt into totality, other than by being an expression switch?</span></div></blockquote></div><br class=""></div></blockquote><div><br></div><div>With the current spec knowing if a switch is total or not depend the last item (it's not fully true) of the switch, if the last item is default, case var, etc<br data-mce-bogus="1"></div><div>so it seems weird to me to have to opt-in upfront instead of at the end of the switch.<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>what about something like<br data-mce-bogus="1"></div><div>  switch(foo) {<br data-mce-bogus="1"></div><div>    case ...<br data-mce-bogus="1"></div><div>    case ...<br data-mce-bogus="1"></div><div>    check-that-this-switch-is-optimistically-total-please;<br data-mce-bogus="1"></div><div>  }<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div><div>obviously, there is perhaps a better keyword than check-that-this-swicth-is-optimistically-total-please, something like implicit-default (using default as a hyphen part is a subconscious message to the fact that using a default here is not expected) or sealed.</div><div><br data-mce-bogus="1"></div><div>Rémi<br data-mce-bogus="1"></div><div><br data-mce-bogus="1"></div></div></div></body></html>