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

All arrays can be adjustable?

    Date: Tue, 19 May 87 19:03:33 MDT
    From: sandra%orion@cs.utah.edu (Sandra J Loosemore)

    It's definitely wrong for make-array to randomly return adjustable arrays
    when the user doesn't specifically ask for them.  

I disagree.  See below.

						      From page 289:  "If 
    make-array is called with the :adjustable, :fill-pointer, and :displaced-to 
    arguments all either unspecified or nil, then the resulting array is 
    guaranteed to be a simple array."  

    This actually sounds like a good problem for the cleanup committee to 
    address.  As I see it, a correct implementation needs to do two things:

    (1) Ensure that things like svref work correctly on things that 
    are supposed to be simple arrays:

	    (svref (make-array 3 :initial-element 'foo) 0)

Of course.

    (2) Ensure that user programs can distinguish arrays that are supposed to
    be simple arrays from those that are not, regardless of whether or not
    simple arrays use the same internal representation as non-simple arrays.

I don't see anything in CLtL that requires this.  It seems like a bad
idea, because it would require all implementations to be more complex
without giving any benefit to the user.  The concept of simple arrays
exists because in some implementations they can be more efficient than
full arrays, not because people have a need to write application programs
that use simple arrays.  Simple arrays don't give any extra expressive

    I do agree that this problem is similar to whether or not the implementation
    has specialized representations for arrays that can only contain a specified
    element type.  However, this issue has the same semantic problems as above.
    Would you like to get a general vector back when you're expecting a simple
    string?  Especially if it doesn't even print like a string?

If you think about it for a moment I think you'll realize how false this
analogy is.  No one is proposing to change how anything prints, or indeed to
do anything other than not enforce a restriction.  The distinction between
strings and general vectors is quite different from the distinction between
simple arrays and full arrays.  I believe Margolin's original analogy was
a different one, referring to the lack of semantic problems when you ask
for an array that can only hold integers and get an array that can hold