Section 2.1 - Program Units
Now that we have very brief flavor of what Ada code looks like, we
need to define some key terms.
More formally, an Ada program is composed of one or more program units.
A program unit can be a:
-
subprogram, which define executable algorithms.
Procedures and functions are both subprograms.
-
package, which defines a collection of entities.
Packages are the main grouping mechanism in Ada, somewhat analogous
to Modula's "module".
-
task unit, which defines a computation that can occur in
parallel with other computations.
-
protected unit, which can coordinate data sharing
between parallel computation. This did not exist in Ada 83.
-
generic units, which helps to make reusable components
(C++'s templates are similar).
The latter three are advanced topics, so we will concentrate for
now on packages and subprograms.
The package is structurally the most important kind of program unit.
Most Ada programs are basically a set of a large number of packages, with
one procedure used as the ``main'' procedure to start the Ada program.
Quiz:
In section 1-1 we defined a simple procedure called Hello.
What kind of program unit was procedure Hello?
- Subprogram
- Package
- Task Unit
You may also:
David A. Wheeler (dwheeler@dwheeler.com)
The master copy of this file is at
"http://www.adahome.com/Tutorials/Lovelace/s2s1.htm".