Next: srfi marray spec, Previous: srfi marray abstract, Up: srfi marray [Index]
The proposed arrays encourage a natural declarative programming style. They allow sharing of most any rectangular part of an array through an affine index mapping, without copying. But imperative style is equally natural.
The design is consistent with the two indexed data structures of Scheme: vectors and strings. The design makes arrays a self–contained type. These statements are illustrated in the following paragraphs.
First, in the one–dimensional case, the arguments of the following relevant calls match exactly.
(vector-set! v k o) (string-set! s k c) (array-set! a k o)
Likewise, make-array
matches make-vector
and
make-string
. An analogue to vector
, string
and
list
is provided, alleviating the lack of an external
representation. Index bounds are specified as for substring
,
lower bound included and upper bound excluded.
Array shapes are specified as arrays. These can be made with a special
procedure shape
that does not have a shape argument. An array
does not retain a dependence to the shape array. For example, mutation
of a shape array is allowed.
Index mappings return multiple values as multiple values.
Array dimensions can begin at any index. In particular, the choice
between 0
and 1
is left to the user. (Shapes and index
objects are zero based, though.)
The ability to pack an index sequence in a vector is useful for implementing higher level operations. (The ability to pack it in a one–dimensional array lets one use, say, a row of a matrix as an index.)
It is not required that vectors not be arrays. It is not required that they be, either.
Next: srfi marray spec, Previous: srfi marray abstract, Up: srfi marray [Index]