5.6. Block Statements


A block statement encloses a sequence of statements optionally preceded by a declarative part and optionally followed by exception handlers.

    block_statement ::=
           end [block_simple_name]; 

If a block statement has a block simple name, this simple name must be given both at the beginning and at the end.

The execution of a block statement consists of the elaboration of its declarative part (if any) followed by the execution of the sequence of statements. If the block statement has exception handlers, these service corresponding exceptions that are raised during the execution of the sequence of statements (see 11.2).


          TEMP : INTEGER;
          TEMP := V; V := U; U := TEMP;
       end SWAP; 


If task objects are declared within a block statement whose execution is completed, the block statement is not left until all its dependent tasks are terminated (see 9.4). This rule applies also to a completion caused by an exit, return, or goto statement; or by the raising of an exception.

Within a block statement, the block name can be used in expanded names denoting local entities such as SWAP.TEMP in the above example (see 4.1.3 (f)).

References: declarative part, dependent task, exception handler, exit statement, expanded name, goto statement, raising of exceptions, return statement, sequence of statements, simple name, task object.