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:

  1. subprogram, which define executable algorithms. Procedures and functions are both subprograms.
  2. package, which defines a collection of entities. Packages are the main grouping mechanism in Ada, somewhat analogous to Modula's "module".
  3. task unit, which defines a computation that can occur in parallel with other computations.
  4. protected unit, which can coordinate data sharing between parallel computation. This did not exist in Ada 83.
  5. 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?

  1. Subprogram
  2. Package
  3. Task Unit

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 (dwheeler@dwheeler.com)

The master copy of this file is at "http://www.adahome.com/Tutorials/Lovelace/s2s1.htm".