HP Pascal/iX Programmer's Guide (31502-90023)

2-: 3
Compilation Unit Structure
A
compilation unit
is a unit of source code that can be compiled
independently of other code (for example, a program is a compilation
unit; a block is not).
You can design your program in two ways:
* As a single compilation unit. In this case you must compile the
entire program at once.
* As two or more compilation units. In this case you can compile
one unit at a time, or you can compile in groups. This is also
known as
separate compilation
.
If your program is small, design it as a single compilation unit; it will
compile quickly because it is small. (The example program in the section
"Program Block" is a single compilation unit.) If your program is large,
design it as two or more compilation units. This saves compilation time
over the course of program development because you can correct and
recompile one unit without recompiling the whole program.
The recommended design for a program with separate compilation units is
modular
; in other words, it is composed of separate compilation units
called
modules
. For compatibility with Pascal/V, HP Pascal also supports
global
and
external compilation units.
You can design your program using
these separate compilation units, if you prefer. You can mix modules and
global and external compilation units.
Modules
A
module
is a compilation unit that defines whatever constants, data
types, variables, functions, and procedures you want. A program or
another module can
import
the module, thereby gaining access to the
definitions that the module
exports
. The definitions that the module
does not export are accessible only to the module itself.
Figure 2-2 illustrates the syntactic structure of a module. For the
exact syntax of a module and its components, refer to the
HP Pascal/iX
Reference Manual
or the
HP Pascal/HP-UX Reference Manual
, depending on
your implementation.
Figure 2-2. Syntactic Structure of a Module
A module's
import declaration
specifies the other modules that it
imports. It can access items in the imported modules' export
declarations. The import declaration can also be used to specify export