dangling else

views updated

dangling else The ambiguity that arises if a language allows constructs of the form if b1 then if b2 then S1 else S2

in which it is not clear which if is associated with the else. Algol 60 resolved the ambiguity by forbidding the use of if immediately after then; Pascal associates the else with the innermost if. Modern languages such as Ada avoid the problem by pairing each if with an explicit end if.