Section 2.2 - Declarations and Bodies

Program units (including subprograms and packages) normally consist of two parts:

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 software components.

There are two special cases to help make programming easier:

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

  1. Declaration
  2. Body

You may also:

PREVIOUS Go back to the previous section

NEXT     Skip to the next section

OUTLINE  Go up to lesson 2 outline

David A. Wheeler (

The master copy of this file is at "".