"J. David Bryan" wrote:
On 6 Nov 2002 at 4:46, CBFalconer wrote:
There is NEVER any reason for an empty else.
Clarity, perhaps? What would be your preference for rewriting:
IF a THEN IF b THEN c ELSE { null } ELSE IF d THEN e;
...without the empty ELSE? This represents the logical conditions:
I think you will find that:
IF a AND b THEN c ELSE IF (NOT a) AND (NOT b) AND d THEN e; or IF a AND b THEN c ELSE IF (NOT (a OR b)) AND d THEN e;
with the parentheses for clarity, covers it exactly, including all do-nothing cases. I have no problems answering the question 'when is c executed' or 'when is e executed' with the above. With the original I do (have a problem).
A Karnaugh map is a very useful thing. It may show that the NOT b term is unnecessary in some applications. Or other economies. In some cases I could conceive of:
IF b THEN c ELSE IF d THEN e;
being satisfactory, even though it doesn't match the original logic, simply by mapping explicit do-nothings and don't cares into a Karnaugh map. This sort of thing can show the uselessness of a, and thus lead to major snippage in the original source. Which is an important form of optimization.