Lady Ada

Ada '83 Language Reference Manual

Copyright 1980, 1982, 1983 owned by the United States Government. Direct reproduction and usage requests to the Ada Information Clearinghouse.


5.6. Block Statements

[PREVIOUS][UP][NEXT]

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

    block_statement ::=
       [block_simple_name:]
          [declare
               declarative_part]
           begin
               sequence_of_statements
          [exception   
               exception_handler
              {exception_handler}]
           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).

Example:

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

Notes:

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.

Style Guide references: 3.3.7 Marker Comments, 5.1.2 Block Names, 5.6.1 Nesting, 5.6.9 Blocks, 5.8.4 Localizing the Cause of an Exception, 9.1.2 Blocks

[INDEX][CONTENTS]


[Ada Information Clearinghouse]

Address any questions or comments to adainfo@sw-eng.falls-church.va.us.