2 Synthesis‎ > ‎Computing‎ > ‎Programming‎ > ‎Ada‎ > ‎

Ada Language

An Ada Program

Every Ada program consists of at least a main program unit that is one file;

   main_program_unit_name.adb

containing the subprogram procedure that will be executed when the program is run.

Before the program can run it must be compiled. When the main program unit is compiled any other program units used by it will automatically be linked in and compiled as necessary.

Ada Program Units

An Ada program is composed of one or more program units. Program units normally consists of two  parts: a specification file;

   program_unit_name.ads

containing;
  • the program unit declaration so the program unit can be visible for use by other program units,
and a body file;

   program_unit_name.adb

containing;
  • the names and parameters of other program units to be used by this program unit, and
  • the implementation of this program unit,
both of which need not  be visible to other units.

Most program units can be compiled separately.  This distinction of the specification and body files, and the ability to  compile units separately, allows a program to be designed, written, and tested  as a set of largely independent software components.

There are five kinds of program units;
  • A subprogram unit for expressing an algorithm as a procedure or function.
  • A package unit offers a collection of logically related entities for use by other program units.
  • A generic unit which defines parametrised forms of packages and subprograms.
  • A task unit for defining a task that may be executed concurrently with other tasks.
  • A protected unit which defines operations for the coordinated sharing of data between tasks.

Other Facilities

Aspect clauses can be used to specify the mapping between types and features of an underlying machine. For example, the user can specify that objects of a given type must be represented with a given number of bits, or that the components of a record are to be represented using a given storage layout. Other features allow the controlled use of low level, nonportable, or implementation-dependent aspects, including the direct insertion of machine code.
 
The predefined environment of the language provides for input-output and other capabilities by means of standard library packages. Input-output is supported for values of user-defined as well as of predefined types. Standard means of representing values in display form are also provided.
 
The predefined standard library packages provide facilities such as string manipulation, containers of various kinds (vectors, lists, maps, etc.), mathematical functions, random number generation, and access to the execution environment.

The specialized annexes define further predefined library packages and facilities with emphasis on areas such as real-time scheduling, interrupt handling, distributed systems, numerical computation, and high-integrity systems.

Finally, the language provides a powerful means of parameterization of program units, called generic program units. The generic parameters can be types and subprograms (as well as objects and packages) and so allow general algorithms and data structures to be defined that are applicable to all types of a given class.