ada Generic Parameters


Example

Ada offers a wide variety of generic parameters which is difficult to translate into other languages. The parameters used during instantiation and as a consequence those on which the generic unit may rely on may be variables, types, subprograms, or package instances, with certain properties. For example, the following provides a sort algorithm for any kind of array:

generic
    type Component is private;
    type Index is (<>);
    with function "<" (Left, Right : Component) return Boolean;
    type Array_Type is array (Index range <>) of Component;
procedure Sort (A : in out Array_Type);