Kalle Olavi Niemitalo <[EMAIL PROTECTED]> writes:

> Raymond Toy <[EMAIL PROTECTED]> writes:
>
>> Earlier versions would trust your declared element-type, but later
>> versions took this out as being unsafe because the compiler and
>> runtime couldn't really prove it was true.
>
> Such trust would also violate the standard.
> If #.(UPGRADED-ARRAY-ELEMENT-TYPE 'foo) and
> #.(UPGRADED-ARRAY-ELEMENT-TYPE 'bar) are type equivalent, then
> (ARRAY foo) and (ARRAY bar) must also be type equivalent.

You're mostly right, but there is a semantic difference in
declarations.

Chapter and verse (from CLHS Declaration TYPE):

   Within the lexical scope of an array type declaration, all
   references to array elements are assumed to satisfy the expressed
   array element type (as opposed to the upgraded array element
   type). A compiler can treat the code within the scope of the array
   type declaration as if each access of an array element were
   surrounded by an appropriate the form.

So 
  (locally
    (declare (type (simple-array simple-string (*)) a))
    (aref (aref a 0) 0))
is equivalent to
  (aref (the simple-string (aref (the (simple-array t (*)) a) 0)) 0)
but of course 
  (subtypep '(simple-array simple-string (*)) '(simple-array t (*)))
and
  (subtypep '(simple-array t (*)) '(simple-array simple-string (*)))
must both return T, T.

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)

Reply via email to