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.

7.1. Package Structure


A package is generally provided in two parts: a package specification and a package body. Every package has a package specification, but not all packages have a package body.

    package_declaration ::= package_specification; 

    package_specification ::=
        package identifier is
        end [package_simple_name] 

    package_body ::=
        package body package_simple_name is
        end [package_simple_name]; 

The simple name at the start of a package body must repeat the package identifier. Similarly if a simple name appears at the end of the package specification or body, it must repeat the package identifier.

If a subprogram declaration, a package declaration, a task declaration, or a generic declaration is a declarative item of a given package specification, then the body (if there is one) of the program unit declared by the declarative item must itself be a declarative item of the declarative part of the body of the given package.


A simple form of package, specifying a pool of objects and types, does not require a package body. One of the possible uses of the sequence of statements of a package body is to initialize such objects. For each subprogram declaration there must be a corresponding body (except for a subprogram written in another language, as explained in section 13.9). If the body of a program unit is a body stub, then a separately compiled subunit containing the corresponding proper body is required for the program unit (see 10.2). A body is not a basic declarative item and so cannot appear in a package specification.

A package declaration is either a library package (see 10.2) or a declarative item declared within another program unit.

References: basic declarative item, body stub, declarative item, declarative part, exception handler, generic body, generic declaration, identifier, library unit, object, package body, program unit, proper body, sequence of statements, simple name, subprogram body, subprogram declaration, subunit, task body, task declaration, type.

Rationale references: 9.1 Motivation, 9.2 Informal Introduction to Packages, 9.2.1 Named Collections of Entities, 9.2.2 Groups of Related Subprograms, 9.2.3 Private Types

Style Guide references: 4.2.1 Minimization of Interfaces, 4.3 Exceptions, 7.1.5 Encapsulating Implementation Dependencies


[Ada Information Clearinghouse]

Address any questions or comments to