[Ada Information Clearinghouse]
Ada '83 Rationale, Sec 16.6: Exceptions and Renaming

"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.6 Exceptions and Renaming

Input-output can very easily be misused, and consequently there is a need for reporting errors. As might be expected, this is done through the raising of certain exceptions, which for convenience are declared together in the package IO_EXCEPTIONS, thus:

package IO_EXCEPTIONS is
  STATUS_ERROR   :  exception;
  MODE_ERROR     :  exception;
  NAME_ERROR     :  exception;
  USE_ERROR      :  exception;
  DEVICE_ERROR   :  exception;
  END_ERROR      :  exception;
  DATA_ERROR     :  exception;
  LAYOUT_ERROR   :  exception;

Note that it would be very inconvenient for these exceptions to be declared in each of the packages SEQUENTIAL_IO, DIRECT_IO, and TEXT_IO. Each instantiation of SEQUENTIAL_IO, for example, would then give rise to a different exception, and it would consequently be tedious to write a general purpose handler, since it would need to refer explicitly to all the instances.

For this reason the three packages all contain renaming declarations such as


This has the advantage that the user (and indeed the writer of the IO package bodies) need not refer explicitly to IO_EXCEPTIONS.

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