For each form of declaration, the language rules define a certain portion of the program text called the scope of the declaration. The scope of a declaration is also called the scope of any entity declared by the declaration. Furthermore, if the declaration associates some notation with a declared entity, this portion of the text is also called the scope of this notation (either an identifier, a character literal, an operator symbol, or the notation for a basic operation). Within the scope of an entity, and only there, there are places where it is legal to use the associated notation in order to refer to the declared entity. These places are defined by the rules of visibility and overloading.
The scope of a declaration that occurs immediately within a declarative region extends from the beginning of the declaration to the end of the declarative region; this part of the scope of a declaration is called the immediate scope. Furthermore, for any of the declarations listed below, the scope of the declaration extends beyond the immediate scope:
In the absence of a subprogram declaration, the subprogram specification given in the subprogram body or in the body stub acts as the declaration and rule (e) applies also in such a case.
Note:
The above scope rules apply to all forms of declaration defined by section 3.1; in particular, they apply also to implicit declarations. Rule (a) applies to a package declaration and thus not to the package specification of a generic declaration. For nested declarations, the rules (a) through
References: basic operation, body stub, character literal, component declaration, declaration, declarative region, discriminant specification, entry declaration, extends, generic declaration, generic parameter declaration, identifier, implicit declaration, occur immediately within, operator symbol, overloading, and 8.7, package declaration, package specification, parameter specification, record type, renaming declaration, subprogram body, subprogram declaration, task declaration, task unit, type declaration, use clause, visibility, visible part.
Rationale references: 11.2 Program Structure
Style Guide references: 4.1.6 Data Coupling, 4.2.3 Restricting Visibility, 7.6.6 Unchecked Deallocation
Address any questions or comments to adainfo@sw-eng.falls-church.va.us.