Ada is an internationally standardized, high-level, object-oriented computer programming language that supports strong typing and structured programming. More information may be found here.
Note that 'Image
can incur implementation defined results (RM 3.5), namely when some graphic characters needed for the String
result are not defined in Character
. Consider the larger repertoires of 'Wide_Image
and 'Wide_Wide_Image
.
The permission to use the attribute __Scalar_Object__'Image
directly on an object was added in Ada 2012-TC-1 (April 2016).
Package provides:
Similarities or analogous in other languages:
The examples should all ensure proper task termination.
The Ada standard library provides for I/O of traditional files of text or binary data, as well as I/O of streamed files. Files of binary data will be sequences of values of a type, while stream files can be sequences of values of possibly different types.
To read and write elements of different types from/to stream files, Ada uses subprograms denoted by types' attributes, namely 'Read
, 'Write
, 'Input
, and 'Output
. The latter two will read and write array bounds, record discriminants, and type tags, in addition to the bare input and output that Read
and 'Write
will perform.
Note how each time a generic package is instantiated with a numeric type. Also, there are both defaults to be set for the whole instance, and also ways to override Width
, say, when calling Put
with this parameter.
All scalar type definitions except enumeration and modular integers may include a range constraint.
A range constraint specifies a lower bound and an upper bound of the set of values to include in the type. For fixed point types, specifying a range is mandatory: values of these types will be understood to be multiples of a small fraction of two, for example, of 1/25. The smaller these fractions become, the more precise the representation, at the cost of range that can be represented using the bits available.
Further aspects of type definitions may be given, such as a desired Size
in bits and other representational items. Ada 2012 adds aspects of contract based programming like Static_Predicate
.