Information Technology Reference
In-Depth Information
The Scope of Labeled Statements
Labeled statements cannot be seen (or accessed) from
outside
the block in which they are
declared.
The scope of a labeled statement is
The block in which it is declared
Any blocks nested inside that block
For example, the code on the left of Figure 9-9 contains several nested blocks, with
their scopes marked. There are two labeled statements declared in Scope B of the program:
increment
and
end
.
The shaded portions on the right of the figure show the areas of the code in which the
labeled statements are in scope.
Code in Scope B, and all the nested blocks, can see and access the labeled statements.
Code from any of the inner scopes can jump
out
to the labeled statements.
Code from outside (Scope A, in this case)
cannot jump into
a block with a labeled
statement.
Figure 9-9.
The scope of labels includes nested blocks.