The first list of declarative items of a package specification is called the visible part of the package. The optional list of declarative items after the reserved word private is called the private part of the package.
An entity declared in the private part of a package is not visible outside the package itself (a name denoting such an entity is only possible within the package). 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).
The elaboration of a package declaration consists of the elaboration of its basic declarative items in the given order.
The visible part of a package contains all the information that another program unit is able to know about the package. A package consisting of only a package specification (that is, without a package body) can be used to represent a group of common constants or variables, or a common pool of objects and types, as in the examples below.
Example of a package describing a group of common variables:
package PLOTTING_DATA is PEN_UP : BOOLEAN; CONVERSION_FACTOR, X_OFFSET, Y_OFFSET, X_MIN, Y_MIN, X_MAX, Y_MAX: REAL; -- see 3.5.7 X_VALUE : array (1 .. 500) of REAL; Y_VALUE : array (1 .. 500) of REAL; end PLOTTING_DATA;
Example of a package describing a common pool of objects and types:
package WORK_DATA is type DAY is (MON, TUE, WED, THU, FRI, SAT, SUN); type HOURS_SPENT is delta 0.25 range 0.0 .. 24.0; type TIME_TABLE is array (DAY) of HOURS_SPENT; WORK_HOURS : TIME_TABLE; NORMAL_HOURS : constant TIME_TABLE := (MON .. THU => 8.25, FRI => 7.0, SAT | SUN => 0.0); end WORK_DATA;
References: basic declarative item, constant, declarative item, direct visibility, elaboration, expanded name, name, number declaration, object declaration, package, package declaration, package identifier, package specification, scope, simple name, type declaration, use clause, variable.
Rationale references: 9.2 Informal Introduction to Packages, 9.3 Technical Issues
Style Guide references: 2.1.7 Pagination, 3.2.4 Program Unit Names, 3.3.3 Program Unit Specification Header, 4.1.1 Separate Compilation Capabilities, 4.1.6 Data Coupling, 4.2.1 Minimization of Interfaces, 4.2.2 Nested Packages, 4.2.4 Hiding Tasks, 4.3.1 Using Exceptions to Help Define an Abstraction, 5.1.4 Naming End Statements, 7.1.3 Comments, 7.1.5 Encapsulating Implementation Dependencies, 8.2.6 Hidden Tasks, 8.3.1 Complete Functionality
Address any questions or comments to email@example.com.