通用参数

Ada 提供各种通用参数,很难翻译成其他语言。在实例化期间使用的参数以及通用单元可能依赖的参数可以是具有某些属性的变量,类型,子程序或包实例。例如,以下提供了任何类型数组的排序算法:

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);