Ada Conformity Assessment Authority      Home Conformity Assessment   Test Suite ARGAda Standard
Annotated Ada Reference Manual (Ada 202x Draft 25)Legal Information
Contents   Index   References   Search   Previous   Next 

A.18.11 The Generic Package Containers.Indefinite_Vectors

{AI95-00302-03} The language-defined generic package Containers.Indefinite_Vectors provides a private type Vector and a set of operations. It provides the same operations as the package Containers.Vectors (see A.18.2), with the difference that the generic formal Element_Type is indefinite.

Static Semantics

{AI95-00302-03} {AI05-0092-1} The declaration of the generic library package Containers.Indefinite_Vectors has the same contents and semantics as Containers.Vectors except:
The generic formal Element_Type is indefinite.
The procedures with the profiles: 
procedure Insert (Container : in out Vector;
                  Before    : in     Extended_Index;
                  Count     : in     Count_Type := 1);
procedure Insert (Container : in out Vector;
                  Before    : in     Cursor;
                  Position  :    out Cursor;
                  Count     : in     Count_Type := 1);
are omitted.
Discussion: These procedures are omitted because there is no way to create a default-initialized object of an indefinite type. Note that Insert_Space can be used instead of this routine in most cases. Omitting the routine completely allows any problems to be diagnosed by the compiler when converting from a definite to indefinite vector. 
The actual Element parameter of access subprogram Process of Update_Element may be constrained even if Element_Type is unconstrained.
{AI12-0035-1} The operations "&", Append, Insert, Prepend, Replace_Element, and To_Vector that have a formal parameter of type Element_Type perform indefinite insertion (see A.18).
{AI12-0111-1} {AI12-0112-1} The description of Tampering_With_Elements_Prohibited is replaced by:
Returns True if tampering with elements is prohibited for Container, and False otherwise.
Reason: Complete replacement of an element can cause its memory to be deallocated while another operation is holding onto a reference to it. That can't be allowed. However, a simple modification of (part of) an element is not a problem, so Update_Element does not cause a problem. 
{AI12-0111-1} {AI12-0112-1} Tampering_With_Cursors_Prohibited is replaced by Tampering_With_Elements_Prohibited in the postcondition for the operations Reference and Constant_Reference.
{AI12-0111-1} The operations Replace_Element, Reverse_Elements, and Swap, and the nested generic unit Generic_Sorting are omitted from the nested package Stable.

Extensions to Ada 95

{AI95-00302-03} The generic package Containers.Indefinite_Vectors is new. 

Inconsistencies With Ada 2012

{AI12-0035-1} Corrigendum: Defined some routines to “perform indefinite insertion”. This could mean that some calls to those routines would now raise Program_Error where they previously worked. However, this is extremely unlikely, as it would require that the package was not implemented in Ada (an Ada allocator would raise Program_Error in these circumstances), and that a program inserted a more nested tagged type (or access discriminant) into a container, and then used that object before its type or discriminant went out of scope. All known implementations are implemented in Ada, so we believe there is no practical incompatibility. As such, we mention this only for completeness.
{AI12-0111-1} Defined the Iterator_View aspect, so that the stable view is used for container element iterators. This means that tampering with elements is prohibited during the entire loop, rather than tampering with cursors being prohibited during the loop, and tampering with elements being prohibited only during the lifetimes of references to the loop parameter. Thus, if a container element iterator does an operation that tampers with elements on the iterated container, that operation will fail a tampering check in Ada 202x (and thus raise Program_Error), while it would have worked in Ada 2012 so long as the loop parameter is not involved. We believe this to be a dubious loop structure that should be rare. Note that this issue only occurs for the indefinite container form, the regular and bounded containers allow such operations at ay time in Ada 202x.

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe