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

defconstant, arrays, and the file compiler



I am trying to do the following:

   (defconstant my-array (make-array '(6)))

   (defun foo ()
     (declare (optimize (speed 3) (safety 0)))
     (setf (svref my-array 3) 5))

Note that I am not attempting to change the binding of the symbol my-array,
merely to set a field in the array to which it is bound.

If I type these into the listener, it works fine: my-array[3] gets 5.
However, if I first compile-file this source and then load the result,
(foo) returns 5 but the value of my-array still has all NILs in it.

This behavior would seem to violate the behavior specified on p.87 of CLtL2
"...the compiler must take care that such 'copies' appear to be EQL to the
object that is the actual value of the constant..."

Is this a bug, or am I misinterpreting CLtL2?  Ie, does "appear to be EQL"
include "altering a field accessed through the copy must alter the same field
as accessed analogously through the other copies"?

Thanks,

-- Bob