[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Indirect arrays
- To: common-lisp at SU-AI
- Subject: Indirect arrays
- From: Guy.Steele at CMU-10A
- Date: Thu, 16 Sep 1982 19:57:00 -0000
I can think of three uses, offhand, for indirect arrays:
(1) Making an n-d array look 1-d so you can map over it.
(2) Making an n-d array look 1-d for some other purpose.
(3) Simulating FORTRAN equivalence, mostly for embedding FOTRAN in LISP.
Perhaps (3) should not be a goal of Common LISP. (1) and (2)
could be mostly satisfied by introducing two functions MAPARRAY
(takes a function and n arrays, which must all have the
same rank and dimensions, and produces a new array of the same
rank and dimensions), and RAVEL (produces a 1-d array with the contents
of the argument array copied into it in row-major order -- note that
this does not require that the argument array actually does store
elements in row-major order, but if it doesn't then RAVEL will
have to do some shuffling).
Indeed, stock hardware atr least will probably use indirection anyway
to be able to do ARRAY-GROW; but the interaction of ARRAY-FROW and
user-specified indirection is very tricky.
Here is a suggestion to alleviate that bad interaction: it should be
an error to shrink an array that has been indirected to. This is
not difficult to check, if one has a bit in the array saying whether
or not it was ever indirected to.
--Guy