<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 18 February 2014 08:31, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 2/17/2014 5:48 AM, Ary Borenszweig wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
On 2/16/14, 5:03 PM, Walter Bright wrote:<br>
</div><div class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It originally was not required, but there was a campaign by a lot of D<br>
users to make it required to deal with the common bug of adding a value<br>
in one switch statement but forgetting to add it to another<br>
corresponding one.<br>
</blockquote>
<br>
Could you show an example of such scenario? I don't get it.<br>
</div></blockquote>
<br>
Having a set of bit flags, and adding another bit flag later, and failing to account for that in existing switch statements.<br>
</blockquote></div><br></div><div class="gmail_extra">It sounds like that's basically the same as final switch, just without the enum key to communicate the strong concept.</div><div class="gmail_extra"><br></div><div class="gmail_extra">
If I were to imagine a solution to that problem I would have also applied final switch, but in the case it's dealing with integers and not enums and therefore can't know which values are valid and tell you that you missed one, it should insert an implicit 'default: assert(0);' (since final switch isn't meant to have 'default' cases), this way any case you don't explicitly handle is considered invalid, and you'll catch your mistake immediately. I expect final switch on enum's must do this anyway (at least in debug)? It's possible to receive a value that's not a recognised enum key; what happens in that case?</div>
<div class="gmail_extra">It seems effectively the same to me.</div></div>