Previous topic | Next topic | Ada Home Page | Index

Subunits

isolate procedures in separate files, compiled separately

procedure stub declared in main program ("super-unit");

         procedure procname (args) is separate;
procedure definition refers to associated main program

         separate (main)
         procedure procname (args) is 
           ...
         end procname;

It is compiled as though it was present in the main program in place of the stub. This means that names declared at that point in the main program are available.

compiling:

  1. main program
  2. then the subunits

An example shows how a main program can be written with a series of stubs for the procedures it calls, and how the procedures can be written as subunits.

Benefits

smaller files, easier editing

smaller compilation units, faster compiling

reduced recompilation (only the changed bits need to be recompiled after any change)

easy incorporation of alternatives


Previous topic | Next topic | Ada Home Page | Index
c-lokan@adfa.oz.au / 17 Feb 1996