[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SEQUENCE-FUNCTIONS-EXCLUDE-ARRAYS (Version 4)
- To: Moon@SCRC-STONY-BROOK.ARPA
- Subject: Re: SEQUENCE-FUNCTIONS-EXCLUDE-ARRAYS (Version 4)
- From: Dave.Touretzky@C.CS.CMU.EDU
- Date: Sat 14 Nov 87 06:01:16-EST
- Cc: CL-Cleanup@SAIL.STANFORD.EDU
- In-reply-to: <19871113002102.3.MOON@EUPHRATES.SCRC.Symbolics.COM>
Here is an explanation of the proper role of COERCE wrt arrays:
My "treat arrays as sequences" proposal was intended to do more than just
extend the applicability of the sequence functions to arrays. It was also
supposed to change the feel of arrays in the language, by implying that shape
isn't all that important; content is what matters.
To preserve the primacy of content, no matter what shape a sequence has (list,
vector, or n-dimensional array), we should be able to convert it to some other
shape and have the behavior of FIND, POSITION, LENGTH, ELT, etc., stay the
same. Looked at this way, it's perfectly obvious that if ARR is a 3x3 array,
then (COERCE 'LIST ARR) should return a nine element list, not a triple of
triples.
As for going from lists to arrays, I suggest that
(COERCE '(ARRAY dims) SEQ)
should be equivalent to
(REPLACE (MAKE-ARRAY 'dims) SEQ)
Note that SEQ may be any type of sequence, including an array; its elements
will be extracted in row-major order as if ELT were used. This definition also
preserves the results of ELT, FIND, POSITION, etc., as long as the source and
destination objects have the same LENGTH. If the source is longer, its
extra elements are lost; if the destination is longer, its extra elements
have undefined initial values.
-- Dave
-------