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.

3.9. Declarative Parts


A declarative part contains declarative items (possibly none).

    declarative_part ::=
       {basic_declarative_item} {later_declarative_item} 

    basic_declarative_item ::= basic_declaration
       | representation_clause | use_clause 

    later_declarative_item ::= body   
       | subprogram_declaration | package_declaration
       | task_declaration       | generic_declaration
       | use_clause             | generic_instantiation 

    body ::= proper_body | body_stub 

    proper_body ::= subprogram_body | package_body | task_body 

The elaboration of a declarative part consists of the elaboration of the declarative items, if any, in the order in which they are given in the declarative part. After its elaboration, a declarative item is said to be elaborated. Prior to the completion of its elaboration (including before the elaboration), the declarative item is not yet elaborated.

For several forms of declarative item, the language rules (in particular scope and visibility rules) are such that it is either impossible or illegal to use an entity before the elaboration of the declarative item that declares this entity. For example, it is not possible to use the name of a type for an object declaration if the corresponding type declaration is not yet elaborated. In the case of bodies, the following checks are performed:

The exception PROGRAM_ERROR is raised if any of these checks fails.

If a subprogram declaration, a package declaration, a task declaration, or a generic declaration is a declarative item of a given declarative part, then the body (if there is one) of the program unit declared by the declarative item must itself be a declarative item of this declarative part (and must appear later). If the body is a body stub, then a separately compiled subunit containing the corresponding proper body is required for the program unit (see 10.2).

References: activation, instantiation, program_error exception, scope, subprogram call, type, visibility.

Elaboration of declarations: 3.1, component declaration 3.7, deferred constant declaration 7.4.3, discriminant specification 3.7.1, entry declaration 9.5, enumeration literal specification 3.5.1, generic declaration 12.1, generic instantiation 12.3, incomplete type declaration 3.8.1, loop parameter specification 5.5, number declaration 3.2.2, object declaration 3.2.1, package declaration 7.2, parameter specification 6.1, private type declaration 7.4.1, renaming declaration 8.5, subprogram declaration 6.1, subtype declaration 3.3.2, task declaration 9.1, type declaration 3.3.1

Elaboration of type definitions: 3.3.1, access type definition 3.8, array type definition 3.6, derived type definition 3.4, enumeration type definition 3.5.1, integer type definition 3.5.4, real type definition 3.5.6, record type definition 3.7

Elaboration of other constructs: context clause 10.1, body stub 10.2, compilation unit 10.1, discriminant part 3.7.1, generic body 12.2, generic formal parameter 12.1 and 12.3, library unit 10.5, package body 7.1, representation clause 13.1, subprogram body 6.3, subunit 10.2, task body 9.1, task object 9.2, task specification 9.1, use clause 8.4, with clause 10.1.1

Rationale references: 3.2 Declarative Parts - Linear Reading

Style Guide references: 2.1.4 Alignment of Declarations, 5.9.6 Initialization


[Ada Information Clearinghouse] Address any questions or comments to