ada Parameterized Types Discriminated record types


In the case of a discriminated record type, some of the components are known as discriminants and the remaining components can depend upon these. The discriminants can be thought of as parameterizing the type and the syntax reveals this analogy. In this example we create a type that provide a square matrix with a positive as parameter :

type Square(X: Positive) is
        S: Matrix(1 .. X, 1 .. X);
    end record;

Then to create a square of 3 by 3, just call yout type Square like this :

Sq: Square(3);