Switch Label List

An integer index is associated with each designational expression in the switch label list. The indexes are 1, 2, 3, and so on through N, where N is the number of designational expressions in the list. These indexes are obtained by counting the designational expressions in order of their appearance in the list. A designational expression in the list can be referenced by subscripting the switch label identifier with a subscript whose value is equal to the index of the designational expression.

Note that the indexing of a switch label list begins at 1.

If a subscript to a switch label identifier yields a value outside the range of the switch label list (that is, less than 1 or greater than N), the statement using the switch label is not executed, and control proceeds to the next statement. Typically, the next statement is a specification of some form of error handling.

The designational expressions in a switch label list are evaluated at the time the subscripted switch label identifier is encountered.

A switch label can reference itself in the switch label list, in which case a stack overflow might occur when the program is executed. For example, assume a switch label is declared as the following:

SWITCH SW := L1, L2, L3, SW[N]

If N equals 4, the designational expression SW[N] references itself indefinitely.