128 lines
7.2 KiB
HTML
128 lines
7.2 KiB
HTML
<!-- Common Lisp HyperSpec (TM), version 7.0 generated by Kent M. Pitman on Mon, 11-Apr-2005 2:31am EDT -->
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>CLHS: Issue ADJUST-ARRAY-DISPLACEMENT Writeup</TITLE>
|
|
<LINK HREF="../Data/clhs.css" REL="stylesheet" TYPE="text/css" />
|
|
<META HTTP-EQUIV="Author" CONTENT="Kent M. Pitman">
|
|
<META HTTP-EQUIV="Organization" CONTENT="LispWorks Ltd.">
|
|
<LINK REL=TOP HREF="../Front/index.htm">
|
|
<LINK REL=COPYRIGHT HREF="../Front/Help.htm#Legal">
|
|
<LINK REL=DISCLAIMER HREF="../Front/Help.htm#Disclaimer">
|
|
<LINK REL=PREV HREF="../Issues/iss002_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss003.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss004_w.htm">
|
|
</HEAD>
|
|
<BODY>
|
|
<H1><A REV=MADE HREF="http://www.lispworks.com/"><IMG WIDTH=80 HEIGHT=65 ALT="[LISPWORKS]" SRC="../Graphics/LWSmall.gif" ALIGN=Bottom></A><A REL=TOP HREF="../Front/index.htm"><IMG WIDTH=237 HEIGHT=65 ALT="[Common Lisp HyperSpec (TM)]" SRC="../Graphics/CLHS_Sm.gif" ALIGN=Bottom></A> <A REL=PREV HREF="../Issues/iss002_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss003.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss004_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue ADJUST-ARRAY-DISPLACEMENT Writeup</H2>
|
|
|
|
<PRE><B>Issue:</B> <A HREF="iss003.htm">ADJUST-ARRAY-DISPLACEMENT</A><P>
|
|
Reference: <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> (CLtL p.297)<P>
|
|
<B>Category:</B> Clarification<P>
|
|
<B>Edit history:</B> Version 1 by Fahlman, 18-Apr-87 (from Steele's list)<P>
|
|
Version 2 by Masinter<P>
|
|
Version 3 by Masinter, 5-Jun-87 (respond to comments)<P>
|
|
Version 4 by Masinter, 23-Nov-87<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
The interaction of <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> and displaced arrays is insufficiently specified<P>
|
|
in the case where the array being adjusted is displaced. <P>
|
|
<P>
|
|
Proposal: ADJUST-ARRAY-DISPLAYCEMENT:RULES<P>
|
|
<P>
|
|
Interaction of adjusting and displacement:<P>
|
|
<P>
|
|
Suppose we are adjusting array A, which is perhaps displaced to B before the<P>
|
|
<A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> call and perhaps to C after the call.<P>
|
|
<P>
|
|
(1) A is not displaced before or after: The dimensions of A are altered, and the<P>
|
|
contents rearranged as appropriate. Additional elements of A are taken from the<P>
|
|
:INITIAL-ELEMENT. The use of :INITIAL-CONTENTS causes all old contents to be<P>
|
|
discarded.<P>
|
|
<P>
|
|
(2) A is not displaced before, but is displaced to C after. As specified in<P>
|
|
CLtL, none of the original contents of A appears in A afterwards; A now contains<P>
|
|
the contents of C, without any rearrangement of C.<P>
|
|
<P>
|
|
(3) A is displaced to B before the call, and is displaced to C after the call.<P>
|
|
(B and C may be the same.) As in case (2), the contents of B do not appear in A<P>
|
|
afterward (unless such contents also happen to be in C). If<P>
|
|
:DISPLACED-INDEX-OFFSET is not specified in the <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> call, it defaults<P>
|
|
to zero; the old offset (into B) is not retained.<P>
|
|
<P>
|
|
(4) A is displaced to B before the call, but not displaced afterward. A gets a<P>
|
|
new "data region", and contents of B are copied into it as appropriate to<P>
|
|
maintain the existing old contents; additional elements of A are taken from the<P>
|
|
:INITIAL-ELEMENT. However, the use of :INITIAL-CONTENTS causes all old contents<P>
|
|
to be discarded.<P>
|
|
<P>
|
|
If array X is displaced to array Y, and array Y is displaced to array Z, and<P>
|
|
array Y is altered by <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A>, array X must now refer to the adjusted<P>
|
|
contents of Y. This means that an implementation may not collapse the chain to<P>
|
|
make X refer to Z directly and forget that the chain of reference passes through<P>
|
|
array Y. (Cacheing techniques are of course permitted, as long as they preserve<P>
|
|
the semantics specified here and in CLtL.)<P>
|
|
<P>
|
|
If X is displaced to Y, it is an error to adjust Y in such a way that it no<P>
|
|
longer has enough elements to satisfy X. This error may be signalled at the<P>
|
|
time of the adjustment, but this is not required.<P>
|
|
<P>
|
|
Note: Omitting the :DISPLACED-TO argument to <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> is equivalent to<P>
|
|
specifying :DISPLACED-TO NIL; in either case, the array is not displaced after<P>
|
|
the call and case (1) or (4) hold.<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
This interaction must be clarified. This set of rules was proposed some time<P>
|
|
ago, as a result of discussions on the Common Lisp mailing list, and this model<P>
|
|
has been adopted by many Common Lisp implementations.<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
Many implementations currently follow the model proposed here, although they<P>
|
|
differ in some detail. For example, Symbolics Common Lisp behaves as indicated<P>
|
|
except for case (4); in that case, it never copies the contents of B, and all<P>
|
|
elements are taken from the :INITIAL-ELEMENT.<P>
|
|
<P>
|
|
<B>Cost to implementors:<P>
|
|
</B><P>
|
|
Some existing implementations may have to be changed, but adopting any other<P>
|
|
model would be worse. Public-domain code implementing this model is available<P>
|
|
from CMU.<P>
|
|
<P>
|
|
<B>Cost to users:<P>
|
|
</B><P>
|
|
This is a relatively uncommon situation, which is the reason it didn't occur to<P>
|
|
the original language designers to specify how it works. Any user code that<P>
|
|
cares about this issue probably already follows the proposed model.<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Clarification of a situation that is currently not addressed by the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>.<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
The cleanup committee supports this clarification.<P>
|
|
<P>
|
|
Some consideration was given to adding DISPLACED-ARRAY-P or ARRAY-DISPLACED-TO<P>
|
|
and ARRAY-DISPLACED-INDEX-OFFSET which would allow access to information as to<P>
|
|
whether an array was or was not displaced. However, these are not part of the<P>
|
|
current proposal.<P>
|
|
<P>
|
|
A similar issue arises with <A REL=DEFINITION HREF="../Body/f_adjust.htm#adjust-array"><B>ADJUST-ARRAY</B></A> and fill pointers, and will be the<P>
|
|
subject of a separate issue.<P>
|
|
<P>
|
|
</PRE>
|
|
<HR>
|
|
|
|
<A REL=NAVIGATOR HREF="../Front/StartPts.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Starting Points]" SRC="../Graphics/StartPts.gif" ALIGN=Bottom></A><A REL=TOC HREF="../Front/Contents.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Contents]" SRC="../Graphics/Contents.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Master.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Index]" SRC="../Graphics/Index.gif" ALIGN=Bottom></A><A REL=INDEX HREF="../Front/X_Symbol.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Symbols]" SRC="../Graphics/Symbols.gif" ALIGN=Bottom></A><A REL=GLOSSARY HREF="../Body/26_a.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Glossary]" SRC="../Graphics/Glossary.gif" ALIGN=Bottom></A><A HREF="../Front/X3J13Iss.htm"><IMG WIDTH=80 HEIGHT=40 ALT="[Issues]" SRC="../Graphics/Issues.gif" ALIGN=Bottom></A><BR>
|
|
|
|
<A REL=COPYRIGHT HREF="../Front/Help.htm#Legal"><I>Copyright 1996-2005, LispWorks Ltd. All rights reserved.</I></A><P>
|
|
</BODY>
|
|
</HTML>
|