<div dir="auto">Academically that may be true, but in the real world that code wouldn't be unreachable. I write code that deals with communication protocols all the time. I can't control what the other side sends. I have two choices. Write a lot of code to validate each and every element is within the proper range, or let the handler for each element, that I have to write anyway, deal with the unexpected values. This is something that comes up a lot dealing with backwards compatibility where one end of a system is upgraded and the other is not (think like mobile apps where you cannot force all phones to switch to the new version simultaneously). A new element will be added to one side that the other doesn't know about. The older code should handle this gracefully, and the else of a case is certainly the most convenient place to do this from the programmer's perspective (or at least mine anyway). <div dir="auto"><br></div><div dir="auto">It can be worked around by casting all parts of the case to integer, but that leads to ugly code. </div><div dir="auto"><br></div><div dir="auto">I'd write up an example but I'm writing from my phone.</div><div dir="auto"><br></div><div dir="auto">Jeff </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Jul 16, 2017 10:49 AM, "Jonas Maebe" <<a href="mailto:jonas@freepascal.org">jonas@freepascal.org</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 16/07/17 16:34, DaWorm wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If the programmer builds a case statement on an enum, that includes all of the possible enum values, and also includes an else clause, to me it seems the programmer is implicitly telling the compiler that there is the possibility of illegal values stored in the enum.<br>
</blockquote>
<br>
Writing unreachable code never has constituted implicitly telling a compiler anything in any programming language. At best, you will get a warning from the compiler that the code is unreachable.<br>
<br>
You don't want a compiler to start second-guessing what you might have meant when you wrote something. Everything must be 100% unambiguous.<br>
<br>
<br>
Jonas<br>
______________________________<wbr>_________________<br>
fpc-devel maillist - <a href="mailto:fpc-devel@lists.freepascal.org" target="_blank">fpc-devel@lists.freepascal.org</a><br>
<a href="http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel" rel="noreferrer" target="_blank">http://lists.freepascal.org/cg<wbr>i-bin/mailman/listinfo/fpc-dev<wbr>el</a><br>
</blockquote></div></div>