Conventional file-based input-output addresses a number of basic issues. These are:
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.