if condition then sequence_of_statements else sequence_of_statements end if; |
is fairly classical. For nested if statements, the if and end if bracket structure avoids the dangling else ambiguity that results from not using end if. An if statement containing elsif alternatives can be used to select among several sequences of statements, depending on different conditions:
if RAIN then -- sequence of statements describing -- what to do when it rains elsif SUN_SHINE then -- sequence of statements describing -- what to do when the sun shines else -- sequence of statements describing -- what to do for other weather conditions end if; |
Strictly speaking, elsif alternatives are redundant: the corresponding statements can always be rewritten in the form of nested if statements. However this nesting is generally awkward and does not convey the correct impression, namely that the alternatives are on the same logical level, and this is quite apart from the fact that the conditions should be evaluated in the order in which they appear.