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

Quick CL Array question



Anyone care to give an opinion on why Common Lisp allows array dimensions to be 0?

(make-array 0) => #<ARRAY 0 simple 175765317>

(array-total-size (make-array 0)) => 0

(make-array '(3 0 3 0)) => #<ARRAY 3x0x3x0 simple 175772333>

(array-total-size (make-array '(3 0 3 0))) => 0

(array-rank (make-array '(3 0 3 0))) => 4

Since such an array has no elements there is no way to store values into or retrieve values from it.
Is the feature simpy intended to be used for adjustable arrays with the intent that the array really
is adjusted before being used?

While I'm on the topic, is the following how zero-dimension arrays are intended to be used?

(defvar *one-elt-array* (make-array nil))

(setf (aref *one-elt-array*) 'the-only-value)

(aref *one-elt-array*)


Thanks for any info,
Guy Footring.