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

Re: SEQUENCE-FUNCTIONS-EXCLUDE-ARRAYS (Version 4)



    Date: Sat 14 Nov 87 06:01:16-EST
    From: Dave.Touretzky@C.CS.CMU.EDU

    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.

Okay; this rationale should go into the SEQUENCE-FUNCTIONS-EXCLUDE-ARRAYS proposal.

    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.

Sure (ignoring wrong argument order to COERCE).  Does this mean coercions from
non-vector arrays to lists should be put back into the proposal, but with a clear
description of what they do (unlike last time)?

    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.

This is pretty hard to understand in light of the proposal that coercing an
array to a vector should share the storage, rather than creating a new vector
and using REPLACE to copy the elements.  So is the semantics we are looking for
 from COERCE to be sharing, copying, or undefined which?