<div dir="ltr"><div dir="ltr">On Tue, Jan 25, 2022 at 4:06 AM Jörg <<a href="mailto:joerg.straube@iaeth.ch">joerg.straube@iaeth.ch</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div lang="DE-CH" style="overflow-wrap: break-word;"><div class="gmail-m_-8800649437438533995WordSection1"><p class="MsoNormal"><span lang="EN-US"><u></u> <u></u></span></p><p class="MsoNormal"><span lang="EN-US">There is a long debate whether an ELSE in a CASE is something good or bad.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">That’s a little bit comparable to LOOP/EXIT: At first sight ELSE looks hand. But if you really had to debug complicated code with a lot of CASE statements you will conclude that the ELSE is quite dangerous.<u></u><u></u></span></p><p class="MsoNormal"><span lang="EN-US">Let’s assume you forgot an important CASE. Instead of being trapped (default behaviour of an uncovered CASE without ELSE) the ELSE catches it, the code goes on with perhaps totally wrong variable settings and the code error (forgotten CASE) is mostly unnoticed!</span></p></div></div></blockquote><div><br></div><div> I agree. Similar potential pitfalls can occur in IF-THEN-ELSIF ladders. It can be a good defensive programming technique to add to the end of these:</div><div><br></div><div>ELSE</div><div>  ASSERT(FALSE)</div><div>END;</div><div><br></div><div>That will trap current (or future, if related code is changed) possibilities that have been overlooked. As a real-life example of this I would have saved myself several hours of head-banging this week if problematic code I have been investigating had been implemented this way. I was able to replace it with a (more efficient) numeric CASE statement on this occasion.</div><div><br></div><div>--</div><div>Chris Burrows</div><div>CFB Software</div><div><a href="http://www.astrobe.com">http://www.astrobe.com</a></div><div><br></div></div></div>