Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

5.7 Exit Statements

An exit_statement is used to complete the execution of an enclosing loop_statement; the completion is conditional if the exit_statement includes a condition.
       exit_statement ::=
          exit [loop_name] [when condition];
Name Resolution Rules
The loop_name, if any, in an exit_statement shall resolve to denote a loop_statement.
Legality Rules
Each exit_statement applies to a loop_statement; this is the loop_statement being exited. An exit_statement with a name is only allowed within the loop_statement denoted by the name, and applies to that loop_statement. An exit_statement without a name is only allowed within a loop_statement, and applies to the innermost enclosing one. An exit_statement that applies to a given loop_statement shall not appear within a body or accept_statement, if this construct is itself enclosed by the given loop_statement.
Dynamic Semantics
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.

Examples of loops with exit statements:
       for N in 1 .. Max_Num_Items loop
          Merge_Item(New_Item, Storage_File);
          exit when New_Item = Terminal_Item;
       end loop;
             --  initial statements
             exit Main_Cycle when Found;
             --  final statements
          end loop Main_Cycle;

Prev | Up | Next | Back | Forward
TOC -- / --.-- / --.--.-- | Index | Search | Syntax | Help

Ada WWW Home -- Email comments, additions, corrections, gripes, kudos, etc. to:

Magnus Kempe --
Copyright statement
Page last generated: 95-03-12