Last modified on 5 January 2009, at 23:55

Ada Programming/Attributes/'First

Ada Lovelace 1838.jpg


X'First, where X is any scalar type (for example integer, enumerated, real), is an attribute that represents the first value (lower bound) in the range of type X. The value returned is of type X.

Note that the Ada attribute X'Pos(0) is not necessarily equivalent to X'First. The underlying position numbers of type X may follow an unusual convention.


type My_Enum is (Enum1, Enum2, Enum3);
type My_Int  is range -1 .. 5;
pragma Assert (My_Enum'First = Enum1);   -- OK
pragma Assert (My_Int'First  = -1);      -- OK
pragma Assert (My_Int'First  =  0);      -- Wrong!

See alsoEdit


Ada Reference ManualEdit