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

Adjustable and displaced arrays



    Date: Wed, 22 May 1985  23:56 EDT
    From: Rob MacLachlan <RAM@CMU-CS-C.ARPA@think>

    I am somewhat confused about the interaction between array adjustment
    and displacement.

    In CLTL p298:

	Note that if the array a is created displaced to array b and
	subsequently array b is given to adjust-array, array a will still
	be displaced to array b; the effects of this displacement and the
	rule of row-major storage order must be taken into account.

    What is this trying to say?  Is this a warning to the user or a threat
    to the implementor?  The obvious interpretation of this statement
    seems to require that all non-simple arrays contain a list of all the
    other array headers that share the same data so that they can be fixed
    up when the array is adjusted.  The answer that you stick in a
    forwarding pointer is not acceptable.

This should be elucidated in the next edition.  If you put this paragraph
beside the descriptions of :DISPLACED-TO and :DISPLACED-INDEX-OFFSET on pages
288-289, and assume that array a is essentially unaffected, one concludes
that array a is still displaced to array b, the mapping between elements
still being determined by taking the elements in row-major order and then
mapping element k of array a to element k+n of array b, where n is the
:displaced-index-offset for array a.  The only difference is that array b,
having been adjusted, may have a different row-major ordering.  (A nasty
problem is that the roles of arrays A and B are reversed on pages 288 and
298!  Sorry about that.)

    The statement in the manual also doesn't answer the question of what
    happens to array b if array a is adjusted.  Is it legal or meaningful
    to have arrays which are both displaced to another array and
    adjustable?  What are the semantics of adjusting such an array?

Well, page 298 says that if A is displaced to X, then after adjustment of A,
A has no relationship to X, nor does the returned result, unless X is
respecified explicitly in the :displaced-to option to ADJUST-ARRAY.
I admit that this fails to state explicitly that X is unaffected.

      Rob