Overview of Ada 2022
3.9 Defaults for generic formal types
Defaults for generic formal types (AI12-0205)
provides easier and more natural generic instantiation. It uses the reserved
words
or use (see RM
12.5).
For example:
generic
type Item_Type is private;
type Item_Count is range <> or use Natural;
-- New syntax using or use
with function "=" (L, R : in Item_Type) return Boolean;
package Lists is
...
end Lists;
This allows the instantiator to be able to provide
a type for the Item_Count, but it can simply
be omitted in ordinary circumstances (in which case Natural
would be used).
© 2021, 2022 Jeff Cousins