On Sat, Oct 12, 2002 at 06:48:01PM +0200, Gerd Moellmann wrote: > "Pierre R. Mai" <[EMAIL PROTECTED]> writes: > > somehow (coerce x 'simple-array) fails. > > Isn't this implementation-dependent behavior? > > * (typep (make-array 1 :fill-pointer 0) 'simple-array) > nil > * (typep (make-array 1) 'simple-array) > t
Actually, no -- COERCE can deal with either its object argument already being of the type specified by its second argument (in which case it returns the first argument without modification), or else for the second argument being a recognizeable subtype of various types, one of which is SEQUENCE. SIMPLE-ARRAY doesn't fit the bill here, but `(SIMPLE-ARRAY ,(ARRAY-ELEMENT-TYPE X) (*)) does. The other datum is that (typep (make-array 1 :fill-pointer 0) 'simple-array) is guaranteed to return NIL, so the first clause of my description of COERCE above never comes into play in this case. It is the second of your examples that is implementation-dependent (an implementation with no arrays that are not adjustable is permitted to return NIL there). Cheers, Christophe -- http://www-jcsu.jesus.cam.ac.uk/~csr21/ +44 1223 510 299/+44 7729 383 757 (set-pprint-dispatch 'number (lambda (s o) (declare (special b)) (format s b))) (defvar b "~&Just another Lisp hacker~%") (pprint #36rJesusCollegeCambridge)
