5.7 Exit Statements
Syntax
Name Resolution Rules
Legality Rules
Dynamic Semantics
{execution (exit_statement)
[partial]} For the execution of an
exit_statement,
the
condition,
if present, is first evaluated. If the value of the
condition
is True, or if there is no
condition,
a transfer of control is done to complete the
loop_statement.
If the value of the
condition
is False, no transfer of control takes place.
8 Several nested loops can be exited by
an
exit_statement
that names the outer loop.
Examples
Examples of loops with exit statements:
for N in 1 .. Max_Num_Items loop
Get_New_Item(New_Item);
Merge_Item(New_Item, Storage_File);
exit when New_Item = Terminal_Item;
end loop;
Main_Cycle:
loop
-- initial statements
exit Main_Cycle when Found;
-- final statements
end loop Main_Cycle;