AREF-1DLISTARRAY and FILLARRAY efficiently in Common Lisp because they take arguments of varying rank. Currently, you have to make a displaced array to work with temporarily and then throw away the displaced array when you're done. In many cases, this is bothersome because there is no a priori reason why they should have to cons at all.ROW-MAJOR-AREF that allows one-dimensional access to the storage backing up a given array assuming the normal row-major storage layout.
ROW-MAJOR-AREF is valid for use with SETF.
row-major-aref array index [Function]
This accesses and returns the element of array specified by index when the elements of array are considered in row-major order. Array may be an array of any dimensionality. row-major-aref may be used with setf. For reference, the following sets of expressions are equivalent:
(row-major-aref array index) ==
(aref (make-array (array-total-size array)
:displaced-to array
:element-type (array-element-type array))
index)
and
(aref array .. subscripts ..) ==
(row-major-aref array (array-row-major-index array .. subscripts ..))
ROW-MAJOR-AREF is a useful, simple addition.
LISTARRAY and FILLARRAY, for example, could be trivially defined by loops that had the following form:
(DOTIMES (I (ARRAY-TOTAL-SIZE ARRAY))
... (ROW-MAJOR-AREF ARRAY I) ...)
Currently, the only really efficient way to write this would involve something like:
(ECASE (ARRAY-RANK ARRAY1)
((0) (SETF (AREF ARRAY1) (AREF ARRAY2)))
((1) (DOTIMES (I (ARRAY-DIMENSION ARRAY 0))
(SETF (AREF ARRAY1 I) (AREF ARRAY2 I))))
((2) (DOTIMES (I (ARRAY-DIMENSION ARRAY 0))
(DOTIMES (I (ARRAY-DIMENSION ARRAY 1))
(SETF (AREF ARRAY1 I J) (AREF ARRAY2 I J)))))
...some finite number of clauses...)
SYS:%1D-AREF.ROW-MAJOR-AREF work efficiently.ROW-MAJOR-AREF is unlikely to be used by any current program.