[Ada Information Clearinghouse]
Ada '83 Rationale, Sec 15.2: Types and Data Representation

"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 15: Representation Clauses and Machine Dependences

15.2 Types and Data Representation

In a typed language, it is important to associate representation clauses with types rather than with individual objects. The basic reasons are simplicity and uniformity. To associate representation clauses with individual objects could mean that these clauses have to be duplicated in many separate declarations and it might therefore be difficult to maintain consistency, especially after repeated modification.

Alternatively, it could mean that a name is associated with each possible representation; and that each object declaration mentions both a type name and a representation name. However such a solution would result in less readable programs. For these reasons, a simpler solution is used in Ada: a representation is associated with a type. Associating representation with type localizes this specification in one place. The specification is thereby associated with all objects of the given type (constants, variables, formal parameters, and so on).

A further advantage of this approach is that, while every type has some representation, the user need not always be concerned with it. Explicit (user-defined) representation clauses are optional: in most cases we are quite willing to let the compiler select an efficient representation for types. This is what we normally expect from compilers although no particular default is guaranteed, so that a small change of a declaration may sometimes be reflected by a more significant change of representation. In certain cases, however, we want to regain control: not because we do not trust the compiler but because we know some information that is essential for the selection of a representation. For example we might know that a given logical type is associated with an external hardware interface, in which case we would write a representation clause to adopt the representation that is dictated by the hardware and thus override any default choice made by the compiler.

Representation clauses may be more or less restrictive; in some cases they fully specify the mapping, while in other cases they merely specify some aspects of a representation.

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