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

Degenerate array axes

What does one mean by (make-array '(0 5)) ?  How should it print?
(assuming that *print-array* is non-null)

The description of array printing on page 369 presumes that the array
is either single-dimensional, or else it has some (i.e., not 0) elements.
Notice how the looping part of the algorithm resets an index to 0 (not -1)
in order to try to access the "element" at index <i1 i2 ... 0 ...>.

I've looked a several CL implementations, and all fail to print such
objects in a readable manner.  Furthermore, they all print the above
array exactly the same as they do (make-array '(0 10)), even though the 
two arrays are not equalp [with *print-array* set to non-null].

It seems clear to me that the algorithm of page 369 does not
provide for a way to distinguish these two arrays, since the
#nA syntax deduces the contents of th dimensions list from
the :initial-contents -- but for arrays of array-total-size equal to
zero, they all have the same "initial contents" even though their
dimensions lists may assume infinitely may values.

Three possible solutions come to mind:
  1) simply rule out degenerate axes as being somehow wrong -- the
     only zero-element arrays must then be vectors
  2) coerce all such beasts into one with all dimensions zero -- e.g.,
     treat the '(0 5) and '(0 10) as if they were '(0 0); then a NIL
     for the :initial-contents would be acceptable.
  3) extend the print syntax of #nA so that it can specify the dimension
     list exactly, and independently of the :initial-contents field.
Anyone have any ideas on this one?

-- JonL --