Rationale for Ada 2005
9.2.1 Incompatibilities with original Ada 95
There are a small number of incompatibilities between
the original Ada 95 and that resulting from various corrections.
1 — A limited type can become nonlimited. Applying
the
Access or
Unchecked_Access
attribute to the current instance of such a type is now illegal. (
AI-225,
3.10(26.e))
This is fairly obscure.
Remember that the current instance rule is about referring to a type
within its own declaration such as
type Strange is limited
record
Me: access Strange := Strange'Unchecked_Access;
...
end record;
This is fine. It only
makes sense to permit the attribute if the type is limited. But a type
can be limited by virtue of having a limited component. for example
type Limp is limited private;
type Strange is
record
Me: access Strange := Strange'Unchecked_Access;
C: Limp;
end record;
If the component is limited private and it turns
out that the full type of the component is not limited after all then
the enclosing type becomes nonlimited. In such a case the attribute is
now not allowed. The cure is to make the enclosing type explicitly limited.
2 — Conversions between unrelated array types
that are limited or (for view conversions) might be by-reference types
are now illegal. This is because they might not have the same representation
and they cannot be copied in order to change the representation. (
AI-246,
4.6(71.j))
3 — The meaning of a record representation
clause and the storage place attributes for the non-default bit order
is now clarified. One consequence is that the equivalence of bit 1 in
word 1 to bit 9 in word 0 for a machine with
Storage_Unit
= 8 no longer applies for the non-default order. (
AI-133,
13.5.1
(31.d) and
13.5.2
(5.c))
4 — Various new freezing rules were added in
order to fix a number of holes in the original rules for Ada 95. (
AI-341,
13.14(20.p))
5 — The type
Unbounded_String
is defined to need finalization. If the partition has
No_Nested_Finalization
and moreover the implementation of
Unbounded_String
does not have a controlled part then it will not be allowed in local
objects now although it was in original Ada 95. Clearly this is extremely
unlikely. (
AI-360,
A.4.5(88.b)).
The same applies to the type
Generator in
Numerics.Float_Random and
Discrete_Random
(
AI-360,
A.5.2(61.a))
and to
File_Type in
Sequential_IO
(
AI-360,
A.8.1(17.b)),
Direct_IO (
AI-360,
A.8.4(20.a)),
Text_IO (
AI-360,
A.10.1(86.c))
and
Stream_IO (
AI-360,
A.12.1(36.b)).
See also
D.7(22.a).
This problem is unlikely with types such as Unbounded_String
which were introduced into Ada 95 at the same time as controlled types
and thus are almost inevitably implemented in terms of controlled types.
It is more likely with the file types that existed in Ada 83 since some
implementations might not have changed them to use controlled types.
6 — It is now illegal to apply the
Access
attribute to a subprogram declared in the specification of a generic
unit in the body of that unit. The usual workaround applies which is
to move the use of the attribute to the private part. (
AI-229,
3.10.2((41.f))
7 — It is now
illegal for the ancestor expression in an extended aggregate to be of
a class wide type or to be dispatching call (probably most readers would
never dream of doing that anyway). Thus if we have tagged type T
and a type NT extended from it and we declare
X: T'Class := ... ;
then the aggregate
NT'(X with ... ) -- illegal
is illegal. We have
to use a type conversion and write
NT'(T(X) with ... ) -- legal
Similarly the ancestor
part cannot be a dispatching call such as F(X)
where the function F is
function F(Y: T) return T is
begin
return Y;
end F;
...
NT'(F(X) with ... ) -- illegal since X class wide
8 — If a generic
library unit and an instance of it both have child units with the same
name then they now hide each other. Thus
generic package G is ... ; -- a generic G
generic package G.C is ... ; -- a child C
with G;
package I is new G; -- the instance
package I.C is ... ; -- child of instance
with G.C; with I.C; -- illegal, both hidden
package P ...
Originally it seems that this was allowed but it
was not specified which package
C would refer
to. This was fairly foolish and confusing. (
AI-377,
8.3(29.z))
9 — A subprogram body acting as a declaration
(that is without a distinct specification) cannot with a private child.
This was allowed by mistake originally and permitted the export of types
declared in private child packages. (
AI-220,
10.1.2(31.f))
10 — For the purposes of deciding whether a
unit can be preelaborable a generic formal object is nonstatic. (
AI-403,
10.2.1(28.f))
11 — Storage pools (and the attribute
Storage_Size)
are not permitted for access to subprogram types. Originally it looked
as if they were allowed provided they were never used (or the size was
zero). (
AI-435,
13.11(43.d))
12 — The rules for the two pragmas
Interrupt_Handler
and
Attach_Handler are the same with respect
to where they are permitted. Originally it appeared that
Interrupt_Handler
could be declared in a place remote from the subprogram it was referring
to. (
AI-253,
C.3.1(25.a))
13 — There are some changes regarding attributes
in remote type and RCI units. These changes primarily concern streams
for limited types. (
AI-240,
E.2.2(18.a),
E.2.3(20.b))
© 2005, 2006 John Barnes Informatics.
Sponsored in part by: