[Ada Information Clearinghouse]
Ada '83 Rationale, Sec 16.2: Basic Requirements

"Rationale for the Design of the
Ada® Programming Language"

[Ada '83 Rationale, HTML Version]

Copyright ©1986 owned by the United States Government. All rights reserved.
Direct inquiries to the Ada Information Clearinghouse at adainfo@sw-eng.falls-church.va.us.

CHAPTER 16: Input-Output

16.2 Basic Requirements

Having decided to treat input-output as an application area, we next need to look at the various requirements that are imposed.

Conventional file-based input-output addresses a number of basic issues. These are:

A major distinction regarding format concerns whether the files are considered solely as repositories of information for later reading by machine, or as the representation of information for later direct interpretation by the human eye. In the first case, the information can conveniently be held (externally) in a format very similar to the internal bitwise representation, whereas the second case requires considerable transformation into some conventional textual format. The two styles are so obviously different that quite different packages seem appropriate for their implementation. Thus we have a package TEXT_IO specifically for the textual format, and in fact two rather similar packages, SEQUENTIAL_IO and DIRECT_IO, for the more general binary input-output - for sequential and for directly indexed files respectively.

Since Ada is a typed language, we need ways of allowing the transmission of data items of different types without infringing the basic rules of the type model. In the case of binary input-output, the approach taken is to insist that each file contains items of just one type. This is conveniently done using the generic mechanism, and so SEQUENTIAL_IO and DIRECT_IO are generic packages with just one formal parameter, namely the type concerned. In the case of TEXT_IO the external form is in all cases a simple stream of characters, and so there is no problem concerning the externally held type. Instead, we need ways of reading and writing values of various internal types from and to this one external character type; this is done by providing a number of overloaded procedures, with parameters of different types, although once again the generic mechanism is required to cope with the variety of numeric and enumeration types, as we shall see later.

In embedded systems there is also a requirement for a much lower level of input-output, whereby data is transferred directly to or from various external devices. Because of the enormous potential generality of devices, it is not possible realistically to provide a great deal in the way of standard facilities. The solution chosen, therefore, is just to provide a simple package LOW_LEVEL_IO which, in essence, suggests a common framework for this area.

The remainder of this chapter considers the more important aspects of these requirements in more detail, with especial emphasis on how they are met through the use of various normal features of Ada.


NEXTPREVIOUSUPTOCINDEX
Address any questions or comments to adainfo@sw-eng.falls-church.va.us.