[Home] [Prev] [Next] [Index]

7.1 Package Structure

7.1 Package Structure

1
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.

2
package_declaration ::= package_specification;

package_specification ::=
      package identifier is
            {basic_declarative_item}
      [private
            {basic_declarative_item}]
      end [package_simple_name]

package_body ::=
      package body package_simple_name is
            [declarative_part]
      [begin
            sequence_of_statements
      [exception
            exception_handler
            {exception_handler}]]
      end [package_simple_name];

3
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.

4
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.

Notes:

5
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.

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

7
References:

*
basic declarative item 3.9

*
body stub 10.2

*
declarative item 3.9

*
declarative part 3.9

*
exception handler 11.2

*
generic body 12.2

*
generic declaration 12.1

*
identifier 2.3

*
library unit 10.1

*
object 3.2

*
package body 7.3

*
program unit 6

*
proper body 3.9

*
sequence of statements 5.1

*
simple name 4.1

*
subprogram body 6.3

*
subprogram declaration 6.1

*
subunit 10.2

*
task body 9.1

*
task declaration 9.1

*
type 3.3



[Home] [Prev] [Next] [Index]

documentation@rational.com
Copyright © 1993-2000, Rational Software Corporation. All rights reserved.