Section 2.2 - Declarations and Bodies
Program units (including subprograms and packages)
normally consist of two parts:
The declaration, which contains information that will
be visible to other program units. The declaration defines the interface
for a program unit.
Sometimes people refer to a declaration as a specification.
They are somewhat analogous to the contents of C ``.h'' files.
The body, which contains implementation details that need not
be visible to other parts.
They are somewhat analogous to the contents of C ``.c'' files.
These separate parts of program units are usually stored in separate files.
This explicit distinction between declaration and body allows a program
to be designed, written, and tested as a set of largely independent
There are two special cases to help make programming easier:
Separate declarations are not required for subprograms
(procedures and functions). If a subprogram has a body but no declaration,
the body of a subprogram can serve as its own declaration.
This makes writing the `hello, world' program in lesson 1 easier -
technically, that simple program is a procedure body that
automatically gives its own declaration.
For some packages, it's not possible to have implementation details.
For example, a package declaration could be just
a collection of constants (like pi and the square root of 2).
In this case, the package must not have a body, since one isn't needed.
This is relatively rare - most packages need
both a declaration and a body.
Which part of a program unit contains the implementation details?
You may also:
David A. Wheeler (email@example.com)
The master copy of this file is at