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

A type specifier question for the CL language theorists.

   Date: Mon, 14 May 90 11:20 PDT
   From: RDP@ALAN.kahuna.decnet.lockheed.com (Robert D. Pfeiffer)

   I just realized that I don't know how to write a type specifier that
   concerns itself with the types of the elements of a list.  That is, I
   can write '(ARRAY INTEGER) to specify an array that consists of
   integers but I can't write '(LIST INTEGER) to do the same for lists.  

   Am I missing something obvious, or is there really no standard CL way to
   do this?

I think there really is no CL way to do this.  (We get a lot of
experience with CL's semi-screwed-up array typing constructs when
using *lisp).  Since an array is sort of by definition a
(semi)fixed-length structure and doesn't do things like car and cdr
(or more importantly rplaca and rplacd) it makes more sense to fix the
element size of an array element.  This way it preallocates a bunch of
memory to hold the array rather than just a bunch of pointers to other
memory (like a list).  I guess this is all kind of obvious, though.
The really funny thing is that at least on the symbolics if you do a
(typeof (make-array '(3) :element-type 'integer :initial-element 0)) I
think the result will be a **general** array, not an integer array.
You can even try to coerce the thing to an integer array, but the
lispm at least does not handle specifically arrays of fixed element

kind of a headache :-/