On 6 Nov 2002 at 15:02, CBFalconer wrote:
I think you will find that:
IF a AND b THEN c ELSE IF (NOT a) AND (NOT b) AND d THEN e;
[...]
with the parentheses for clarity, covers it exactly....
Presuming that we discard the "AND NOT b" as noted in your followup, that still yields a different result if "a" has side-effects. If "a", for example, is a function to "get a character," then you see the problem, i.e., two characters are processed instead of the intended one.
It is not my intent to belabor the point, but rather simply to take exception to your original assertion that it is "NEVER" appropriate to use an empty ELSE. Style rules that contain absolute prohibitions against language features are "NEVER" correct. ;-) DeMorgan-izing a condition to avoid the empty ELSE may improve clarity or detract from it, depending on how hard it is for the reader to understand the transformed conditional (i.e., how convoluted it becomes). For instance:
IF not_received AND not_transmitted THEN a ELSE b
...is much easier for me to understand than:
IF NOT not_received OR NOT not_transmitted THEN b ELSE a
...even if statement "a" introduces potentially introduces an empty ELSE. Another example is a FOR loop that introduces otherwise unneeded Boolean variables to avoid a GOTO as a loop exit condition (because of a style rule that asserts that GOTOs are never appropriate).
I would agree with such style rules if "NEVER" were changed to "rarely."
-- Dave