[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Shape revision

This is a concrete idea for revising the shape representation. At
present we have

* (shape bound ...) to make arrays that represent shapes
* (array-shape arr) to access the shape of the array
  (array-rank arr)  to access the number of dimensions of arr
  (make-array shape . obj)
  (array shape obj ...)
  (share-array arr shape proc)

and some language about it not being alright to mutate a shape.

Now I propose to replace (array-shape arr) with

  (array-start arr d)  for the start index of arr along dimension d
  (array-end arr d)    for the end index of arr along dimension d

and specify only that a (shape bound ...) is suitable input to
make-array, array and share-array - in particular, it need not be an
array. (It occurred to me that "begin" is not a noun, hence "start".
These better be short.)

People can easily write array-shape themselves, with the practical
advantage that the result will be newly allocated and mutable,
together with array->shape to create the corresponding shape object.

When people don't need the shape as a data structure, they can write
shorter and more transparent code with array-start and array-end.

Implementors can represent shapes in arrays more efficiently.