On May 6, 2009, at 12:28 PM, Nikodemus Siivola wrote:
> Add a new slot, ARRAY-DISPLACED-FROM, to array-headers, and store a
> list of weak backpointers to arrays displaced to the array in
> question there. SET-ARRAY-HEADER (as part of ADJUST-ARRAY) now
> checks this list, and signals an error if any of the displaced-from
> arrays is larger than the new size.
This seems somewhat poor, as it means that programs' proper execution
depends on when the GC collects the discarded displaced arrays.
E.g. the following outline of a program seems like it should be
perfectly fine, since the displaced-from array is never used after the
adjustment of the base array, but will break after this change. And
adding invocations of the GC in the right places could get it to work
again. That seems pretty odd to me.
(defun read-data-into (arr)
(adjust-array arr 100)
(fill arr 5))
(defun process-data (arr)
(assert (= (reduce #'+ arr) 50)))
(defun run ()
(let ((x (make-array 0 :adjustable t)))
(process-data (make-array 10 :displaced-to x))
(adjust-array x 0))))
Might it not be better to shrink or mark as unusable the displaced-