8.1. Declarative Region


A declarative region is a portion of the program text. A single declarative region is formed by the text of each of the following:

In each of the above cases, the declarative region is said to be associated with the corresponding declaration or statement. A declaration is said to occur immediately within a declarative region if this region is the innermost region that encloses the declaration, not counting the declarative region (if any) associated with the declaration itself.

A declaration that occurs immediately within a declarative region is said to be local to the region. Declarations in outer (enclosing) regions are said to be global to an inner (enclosed) declarative region. A local entity is one declared by a local declaration; a global entity is one declared by a global declaration.

Some of the above forms of declarative region include several disjoint parts (for example, other declarative items can be between the declaration of a package and its body). Each declarative region is nevertheless considered as a (logically) continuous portion of the program text. Hence if any rule defines a portion of text as the text that extends from some specific point of a declarative region to the end of this region, then this portion is the corresponding subset of the declarative region (for example it does not include intermediate declarative items between the two parts of a package).


As defined in section 3.1, the term declaration includes basic declarations, implicit declarations, and those declarations that are part of basic declarations, for example, discriminant and parameter specifications. It follows from the definition of a declarative region that a discriminant specification occurs immediately within the region associated with the enclosing record type declaration. Similarly, a parameter specification occurs immediately within the region associated with the enclosing subprogram body or accept statement.

The package STANDARD forms a declarative region which encloses all library units: the implicit declaration of each library unit is assumed to occur immediately within this package (see sections 8.6 and 10.1.1).

Declarative regions can be nested within other declarative regions. For example, subprograms, packages, task units, generic units, and block statements can be nested within each other, and can contain record type declarations, loop statements, and accept statements.

References: accept statement, basic declaration, block statement, body stub, declaration, discriminant part, discriminant specification, entry declaration, formal part, generic body, generic declaration, generic parameter declaration, implicit declaration, incomplete type declaration, library unit, loop statement, package, package body, package declaration, parameter specification, private type declaration, record representation clause, record type, renaming declaration, standard package, subprogram body, subprogram declaration, subunit, task body, task declaration, task unit.