next up previous contents
Next: Simple Value Classes Up: Predefined Classes Previous: Predefined Classes

Array Classes

  A class declaration tex2html_wrap_inline2587 with bounds declares an array class. The number of bounds is called the dimension of the array class. The dimension is part of the type defined by the array class. The bounds are transformed into readonly attribute declarations readonly m: INT; readonly n: INT,.... These attributes are initialized whenever a new object of the type is created by a type constructor # tex2html_wrap_inline2593 . In case of the predefined class ROW [asize] (T) the attribute asize is constant and its value is part of the type.

An array class declaration D may inherit an array class C taking over C's bounds including their names. This is indicated by supplying the symbol * in the inheritance as parameter for the index bounds to be taken over. The number of stars must match the dimension of D. The class must not inherit multiply in this way.

Every array class should define the procedures aget and aset with the appropriate number and types of parameters.

The replacements of a[i,j] by a.aget(i,j) or a.aset(i,j,v) described in 4.5 are made in any case, also if a does not belong to an array class. The correct number of indices in a[i,j] is determined by the (method) types of aget and aset respectively.

A class specifier must give values to all its bounds when it is used as a type constructor or when it is of the form ROW[asize](T). In all other cases some bounds may be replaced by stars. In case of an assignment a:= b to a variable declared by a: C[10,*] it is checked that the first bound of b has the value 10 whereas the second bound is not checked.

Hint: Since for value types v:V is equivalent to v:#V which is short for v:V:=#V, and since an explicit size must be given for ARR creation, a specification a:ARR[*]; is legal for method parameters only. tex2html_wrap_inline1707

The built-in classes for handling arrays are:


next up previous contents
Next: Simple Value Classes Up: Predefined Classes Previous: Predefined Classes

Martin Trapp
Mon Feb 17 16:49:16 MET 1997