When operating on an untagged type, if it has any primitive operations, and the
first parameter of an operation is of the type (or is an access parameter with
an anonymous type that designates the type), you may invoke these operations
using an object.op(...)
notation, where the parameter that would normally be
the first parameter is brought out front, and the remaining parameters (if any)
appear within parentheses after the name of the primitive operation.
This same notation is already available for tagged types. This extension allows for untagged types. It is allowed for all primitive operations of the type independent of whether they were originally declared in a package spec or its private part, or were inherited and/or overridden as part of a derived type declaration occuring anywhere, so long as the first parameter is of the type, or an access parameter designating the type.
For example:
generic type Elem_Type is private; package Vectors is type Vector is private; procedure Add_Element (V : in out Vector; Elem : Elem_Type); function Nth_Element (V : Vector; N : Positive) return Elem_Type; function Length (V : Vector) return Natural; private function Capacity (V : Vector) return Natural; -- Return number of elements that may be added without causing -- any new allocation of space type Vector is ... with Type_Invariant => Vector.Length <= Vector.Capacity; ... end Vectors; package Int_Vecs is new Vectors(Integer); V : Int_Vecs.Vector; ... V.Add_Element(42); V.Add_Element(-33); pragma Assert (V.Length = 2); pragma Assert (V.Nth_Element(1) = 42);
Link to the original RFC:
‘https://github.com/AdaCore/ada-spark-rfcs/blob/master/prototyped/rfc-prefixed-untagged.rst
’