From: Wei Jen Yeh
Subject: displacing arrays (Was: ,@ not working)
Date: 
Message-ID: <18741@ector.cs.purdue.edu>
Hello,

  First, thanks for the several postings and emails for pointing out my
mistake, and for the code examples.  I tried the method of displacing
arrays.  However, it turned out the new array and the displaced array
do not have EQ components (the particular Lisp I'm talking about is AKCL,
which is CLtL1).  This won't do for this particular case, since the array
is used as a state vector, where each component holds a simple value or
an array value (stored at a central place).  To speed up testing of equality
of state vectors, no duplicate array values are allowed and EQ is used
to test the components.  I'm now using the (corrected) version I wrote.

  Does CLtL2 specify the equality relationship between components of the
new array and the displaced array?

Wei Jen Yeh                      ···@cs.purdue.edu
                                 Department of Computer Science
                                 Purdue University
                                 West Lafayette, Indiana
From: Barry Margolin
Subject: Re: displacing arrays (Was: ,@ not working)
Date: 
Message-ID: <vllkaINNq4f@early-bird.think.com>
In article <·····@ector.cs.purdue.edu> ···@cs.purdue.EDU (Wei Jen Yeh) writes:
>  First, thanks for the several postings and emails for pointing out my
>mistake, and for the code examples.  I tried the method of displacing
>arrays.  However, it turned out the new array and the displaced array
>do not have EQ components (the particular Lisp I'm talking about is AKCL,
>which is CLtL1).  This won't do for this particular case, since the array
>is used as a state vector, where each component holds a simple value or
>an array value (stored at a central place).  To speed up testing of equality
>of state vectors, no duplicate array values are allowed and EQ is used
>to test the components.  I'm now using the (corrected) version I wrote.
>
>  Does CLtL2 specify the equality relationship between components of the
>new array and the displaced array?

Let me make sure I understand the problem.

You're given OLD-ARRAY, and you create DISPLACED-ARRAY with something like:

	(make-array (array-total-size old-array)
		:element-type (array-element-type old-array)
		:displaced-to old-array)

You also make NEW-ARRAY and NEW-DISPLACED-ARRAY similarly, and then do

	(setf (aref new-displaced-array i) (aref displaced-array i))

And then you claim that (aref new-array <indices>) is not EQ to (aref
old-array <indices>)?

What data types are you storing in the array?  You just said "simple
values", which doesn't tell me much.  If they are numbers or characters,
Common Lisp doesn't specify whether equivalent values are EQ, and you
should be using EQL to compare them (this is why EQL is the default
equivalence predicate for all the sequence functions).  EQ should be
maintained for other data types, but it's always the case that after an
assignment, the source and destination are EQL.

If you're not using numbers or characters, then please give an example that
shows the problem you're having.
-- 
Barry Margolin
System Manager, Thinking Machines Corp.

······@think.com          {uunet,harvard}!think!barmar