Rationale for Ada 2005: 7. Epilogue

RUSTOP
BACKNEXT

ENG

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

  1        type Strange is limited
  2                record
  3                        Me : access Strange := Strange'Unchecked_Access;
  4                        ...
  5                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

  1        type Limp is limited private;
  2        type Strange is
  3                record
  4                        Me : access Strange := Strange'Unchecked_Access;
  5                        C  : Limp;
  6                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

  1        X : T'Class := ... ;

@ then the aggregate

  1        NT'(X with ... ) -- illegal

@ is illegal. We have to use a type conversion and write

  1        NT'(T(X) with ... ) -- legal

@ Similarly the ancestor part cannot be a dispatching call such as F(X) where the function F is

  1        function F (Y : T) return T is
  2        begin
  3                return Y;
  4        end F;
  5        ...
  6        NT'(F (X) with ... ) -- illegal since X class wide

@ Again it can be fixed by a suitable conversion to a specific type. (AI-306, 4.3.2((13.b)) 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

  1        generic package G is ... ; -- a generic G
  2        generic package G.C is ... ; -- a child C
  3        with G; package I is new G; -- the instance
  4        package I.C is ... ; -- child of instance
  5        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))

2.2 Inconsistencies with original Ada 95

@ There are a small number of inconsistencies between the original Ada 95 and that resulting from various corrections. 1 – The function Exception_Identity applied to the value Null_Occurrence now returns Null_Id whereas it originally raised Constraint_Error in Ada 95. See paper 5, section 2. (AI-241, 11.4.1(19.y)) 2 – The procedure Raise_Exception applied to the value Null_Id now raises Constraint_Error whereas it originally did nothing (and thus returned). See paper 5, section 4. (AI-466, 11.4.1(19.aa)) 3 – Rounding of static real expressions is now implementation-defined whereas it was originally defined as away from zero. The reason for the change is to match the behaviour of the hardware; this also means that static and non-static expressions are more likely to get the same answer which is comforting. (AI-268, 4.9(44.s)) 4 – The lower bounds of strings returned by functions Exception_Name, Exception_Message, and Exception_ Information (and wide versions) are now defined to be 1. (AI-378, 417, 11.4.1(19.z)) Similarly the bounds of the various functions Slice are now defined. (AI-238, A.4.4(106.e)) 5 – There are some changes regarding stream attributes. (AI-108, 13.13.2(60.g) and AI-195, 13.13.2(60.h)) 6 – There are changes regarding truncation of stream files. (AI-283, A.12.1(36.a)) 7 – There is a potential inconsistency regarding the use of Internal_Tag outside of streaming. However, there was an implementation permission to do as is now required and so programs were not portable anyway. (AI-279, 3.9(33.b)) 8 – The procedure Update in Interfaces.C.Strings no longer adds a nul character. (AI-242, B.3.1(60.a)) 3 Unfinished topics A number of topics which seemed to be good ideas initially were abandoned for various reasons. Usually the reason was simply that a good solution could not be produced in the time available and the trouble with a bad solution is that it is hard to put it right later. In other cases it is now felt that the topic deserved further consideration in the light of better understanding; sometimes there was fairly general agreement that the current situation was not ideal and ought to be improved, nevertheless there was no agreement on what should be done. And in some cases the good idea seemed a bad idea after further discussion.

@ So it might be that when Ada is next revised these further features might be reconsidered and so perhaps this section might be called forthcoming attractions. But on the other hand maybe other matters will need to be dealt with in the light of user experience with Ada 2005.

@ The following subsections briefly outline the main topics – for a fuller discussion, consult the text of the Ada Issue concerned.

Rationale for Ada 2005: 7. Epilogue

ENGRUSTOP
BACKNEXT

Îçåëåíåíèÿ è áëàãîóñòðîéñòâà òåððèòîðèè ïîñàäêà äåðåâüåâ è êóñòàðíèêîâ. . .