Overview of Ada 2022
Jeff Cousins
Contents   Index   Search   Previous   Next 

3.8 Aspects for Generic Formal Parameters

Previously, language-defined aspects were not allowed for generic formal parameters, but now several are allowed:
As mentioned in the Parallelism section (see 2.3), Nonblocking subprograms (AI12-0064-2) allows the Nonblocking aspect to be specified for generic formal parameters, and Fixes for Nonblocking (AI12-0374-2) clarifies that, at the point of instantiation, the Nonblocking aspects of the actual generic parameters are and-ed with the Nonblocking aspects of the operations within the generic.
The new aspect for types, Default_Initial_Condition (Default_Initial_Condition for types (AI12-0265) – see 3.10) is allowed on generic formal private types.
Contracts for generic formal parameters (AI12-0272) allows Pre and Post on generic formal (nonabstract) subprograms. For example:
generic
   type Foo is ...
   with function Reduce (Obj : Foo) return Integer
      with Post => Reduce'Result in -9 .. 9;
package Gen is
   ...
end Gen;
These conditions are "add"-ed to those for the actual subprogram.
Atomic, Volatile, and Independent generic formal types (AI12-0282). The aspects Atomic, Volatile, Independent, Atomic_Components, Volatile_Components, and Independent_Components can now be specified for generic formal types. The actual type must have a matching specification, though for backward compatibility reasons the actual types can be Atomic, etc., without the formal types necessarily matching.

Contents   Index   Search   Previous   Next 
© 2021, 2022 Jeff Cousins