Next: Compatibility with DEC Ada 83, Up: Compatibility Guide
Ada 95 is designed to be highly upwards compatible with Ada 83. In particular, the design intention is that the difficulties associated with moving from Ada 83 to Ada 95 should be no greater than those that occur when moving from one Ada 83 system to another.
However, there are a number of points at which there are minor incompatibilities. The Ada 95 Annotated Reference Manual contains full details of these issues, and should be consulted for a complete treatment. In practice the following are the most likely issues to be encountered.
Standard.Character
is now the full 256 characters of Latin-1,
whereas in most Ada 83 implementations it was restricted to 128 characters.
This may show up as compile time or runtime errors. The desirable fix is to
adapt the program to accommodate the full character set, but in some cases
it may be convenient to define a subtype or derived type of Character that
covers only the restricted range.
abstract
, aliased
, protected
,
requeue
, tagged
, and until
are reserved in Ada 95.
Existing Ada 83 code using any of these identifiers must be edited to
use some alternative name.
A particular case is that representation pragmas (including the
extended DEC Ada 83 compatibility pragmas such as Export_Procedure
), cannot
be applied to a subprogram body. If necessary, a separate subprogram
declaration must be introduced to which the pragma can be applied.
Numeric_Error
is now the same as Constraint_Error
Numeric_Error
is a renaming of Constraint_Error
.
This means that it is illegal to have separate exception handlers for
the two exceptions. The fix is simply to remove the handler for the
Numeric_Error
case (since even in Ada 83, a compiler was free to raise
Constraint_Error
in place of Numeric_Error
in all cases).
String
) as
the actual for a generic formal private type, but then the instantiation
would be illegal if there were any instances of declarations of variables
of this type in the generic body. In Ada 95, to avoid this clear violation
of the contract model, the generic declaration clearly indicates whether
or not such instantiations are permitted. If a generic formal parameter
has explicit unknown discriminants, indicated by using (<>)
after the
type name, then it can be instantiated with indefinite types, but no
variables can be declared of this type. Any attempt to declare a variable
will result in an illegality at the time the generic is declared. If the
(<>)
notation is not used, then it is illegal to instantiate the generic
with an indefinite type. This will show up as a compile time error, and
the fix is usually simply to add the (<>)
to the generic declaration.
All implementations of GNAT provide a switch that causes GNAT to operate in Ada 83 mode. In this mode, some but not all compatibility problems of the type described above are handled automatically. For example, the new Ada 95 protected keywords are not recognized in this mode. However, in practice, it is usually advisable to make the necessary modifications to the program to remove the need for using this switch.