7.1 Package Specifications and Declarations
Syntax
Legality Rules
Static Semantics
An entity declared in the private part of a package
is visible only within the declarative region of the package itself (including
any child units — see
10.1.1). In
contrast, expanded names denoting entities declared in the visible part
can be used even outside the package; furthermore, direct visibility
of such entities can be achieved by means of
use_clauses
(see
4.1.3 and
8.4).
Dynamic Semantics
NOTE 1 The visible part of a package
contains all the information that another program unit is able to know
about the package.
NOTE 2 If a declaration occurs immediately
within the specification of a package, and the declaration has a corresponding
completion that is a body, then that body has to occur immediately within
the body of the package.
Examples
Example of a package
declaration:
package Rational_Numbers is
type Rational is
record
Numerator : Integer;
Denominator : Positive;
end record;
function "="(X,Y : Rational) return Boolean;
function "/" (X,Y : Integer) return Rational; -- to construct a rational number
function "+" (X,Y : Rational) return Rational;
function "-" (X,Y : Rational) return Rational;
function "*" (X,Y : Rational) return Rational;
function "/" (X,Y : Rational) return Rational;
end Rational_Numbers;
There are also many examples of package declarations
in the predefined language environment (see
Annex
A).
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe