[top] [prev] [next]

Type operations

              ISTYPE  (x: Reference; T: RefType) : BOOLEAN
ISTYPE(x, T) is TRUE if and only if x is a member of T. T must be an object type or traced reference type, and x must be assignable to T.
              NARROW  (x: Reference; T: RefType): T
NARROW(x, T) returns x after checking that x is a member of T. If the check fails, a runtime error occurs. T must be an object type or traced reference type, and x must be assignable to T.

              TYPECODE (T: RefType)       : CARDINAL
                       (r: REFANY)        : CARDINAL
                       (r: UNTRACED ROOT) : CARDINAL
Every object type or traced reference type (including NULL) has an associated integer code. Different types have different codes. The code for a type is constant for any single execution of a program, but may differ for different executions. TYPECODE(T) returns the code for the type T and TYPECODE(r) returns the code for the allocated type of r. It is a static error if T is REFANY or is not an object type or traced reference type.

              ORD  (element: Ordinal): Integer
              VAL  (i: Integer; T: OrdinalType): T
ORD converts an element of an enumeration to the integer that represents its position in the enumeration order. The first value in any enumeration is represented by zero. If the type of element is a subrange of an enumeration T, the result is the position of the element within T, not within the subrange.

VAL is the inverse of ORD; it converts from a numeric position i into the element that occupies that position in an enumeration. If T is a subrange, VAL returns the element with the position i in the original enumeration type, not the subrange. It is a checked runtime error for the value of i to be out of range for T.

If n is an integer of type T, ORD(n) = VAL(n, T) = n.

              NUMBER (T: OrdinalType)    : CARDINAL
                     (A: FixedArrayType) : CARDINAL
                     (a: Array)          : CARDINAL
For an ordinal type T, NUMBER(T) returns the number of elements in T. For a fixed array type A, NUMBER(A) is defined by NUMBER(IndexType(A)). Similarly, for an array a, NUMBER(a) is defined by NUMBER(IndexType(a)). In this case, the expression a will be evaluated only if it denotes an open array.

              FIRST (T: OrdinalType)    : BaseType(T)
                    (T: FloatType)      : T
                    (A: FixedArrayType) : BaseType(IndexType(A))
                    (a: Array)          : BaseType(IndexType(a))

              LAST  (T: OrdinalType)    : BaseType(T)
                    (T: FloatType)      : T
                    (A: FixedArrayType) : BaseType(IndexType(A))
                    (a: Array)          : BaseType(IndexType(a))
For a non-empty ordinal type T, FIRST returns the smallest value of T and LAST returns the largest value. If T is the empty enumeration, FIRST(T) and LAST(T) are static errors. If T is any other empty ordinal type, the values returned are implementation-dependent, but they satisfy FIRST(T) > LAST(T).

For a floating-point type T, FIRST(T) and LAST(T) are the smallest and largest values of the type, respectively. On IEEE implementations, these are minus and plus infinity.

For a fixed array type A, FIRST(A) is defined by FIRST(IndexType(A)) and LAST(A) by LAST(IndexType(A)). Similarly, for an array a, FIRST(a) and LAST(a) are defined by FIRST(IndexType(a)) and LAST(IndexType(a)). The expression a will be evaluated only if it is an open array. Note that if a is an open array, FIRST(a) and LAST(a) have type INTEGER.

              BITSIZE  (x: Any)  : CARDINAL
                       (T: Type) : CARDINAL

              BYTESIZE (x: Any)  : CARDINAL
                       (T: Type) : CARDINAL

              ADRSIZE  (x: Any)  : CARDINAL
                       (T: Type) : CARDINAL
These operations return the size of the variable x or of variables of type T. BITSIZE returns the number of bits, BYTESIZE the number of 8-bit bytes, and ADRSIZE the number of addressable locations. In all cases, x must be a designator and T must not be an open array type. A designator x will be evaluated only if its type is an open array type.

[top] [prev] [next]