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

*To*: common-lisp@SU-AI.ARPA*Subject*: Degenerate array axes*From*: Guy Steele <gls@THINK.ARPA>*Date*: Thu, 6 Jun 85 10:34 EDT*Cc*: gls@THINK.ARPA*In-reply-to*: Your message of 6 Jun 85 08:43-EDT

Date: 06 Jun 85 0543 PDT From: Jon White <JLW@SU-AI.ARPA@think> 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 ...>. Eeee-yuk! This boner is completely my fault, and I feel very bad about it, inasmuch as I put a lot of study into how APL hackers solved this problem. (Essentially what they do is to exhibit a NON-empty array showing typical components, and then say "the array I'm talking about is just like this one except that thus-and-so axes are zero". I'm not crazy about this solution, since we don't have the same problem of prototypes [their technical term for what you get when you take the "CAR" of an empty array] that APL does.) 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 -- Under option (3), how about #A<dimension-list><initial-element> ? This would provide a notation for empty arrays, as well as a concise notation for arrays with all elements the same (EQL). For empty arrays the initial element doesn't especially matter, so use (). So one would have (make-array '(0 5)) => #A(0 5)() (make-array '(0 10)) => #A(0 10)() Of course, this is a non-trivial extension to the language. --Guy

- Prev by Date:
**Degenerate array axes** - Next by Date:
**Degenerate array axes** - Previous by thread:
**Degenerate array axes** - Next by thread:
**Degenerate array axes** - Index(es):