149 lines
9 KiB
HTML
149 lines
9 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 CONSTANT-COLLAPSING 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/iss079_w.htm">
|
||
|
<LINK REL=UP HREF="../Issues/iss080.htm">
|
||
|
<LINK REL=NEXT HREF="../Issues/iss081_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/iss079_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss080.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss081_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
||
|
|
||
|
<HR>
|
||
|
|
||
|
|
||
|
|
||
|
<H2>Issue CONSTANT-COLLAPSING Writeup</H2>
|
||
|
|
||
|
<PRE><B>Forum:</B> Compiler<P>
|
||
|
<B>Issue:</B> <A HREF="iss080.htm">CONSTANT-COLLAPSING</A><P>
|
||
|
<B>References:</B> CLtL p. 78, 87<P>
|
||
|
Issue <A HREF="iss083.htm">CONSTANT-MODIFICATION</A><P>
|
||
|
Issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A><P>
|
||
|
Issue <A HREF="iss143.htm">EQUAL-STRUCTURE</A><P>
|
||
|
Issue <A HREF="iss282.htm">QUOTE-SEMANTICS</A><P>
|
||
|
<B>Category:</B> CHANGE<P>
|
||
|
<B>Edit History:</B> V1, 07 Nov 1988, Sandra Loosemore<P>
|
||
|
V2, 12 Dec 1988, Sandra Loosemore<P>
|
||
|
V3, 03 Jan 1989, Sandra Loosemore<P>
|
||
|
V4, 06 Jan 1989, Sandra Loosemore<P>
|
||
|
V5, 11 Mar 1989, Sandra Loosemore<P>
|
||
|
V6, 22 Mar 1989, Sandra Loosemore (comments from Moon)<P>
|
||
|
<B>Status:</B> Ready for release<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Problem Description:<P>
|
||
|
</B><P>
|
||
|
CLtL states that an implementation is permitted to "collapse" or<P>
|
||
|
coalesce constants appearing in code to be compiled if they are <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>.<P>
|
||
|
The definition of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> does not permit coalescing of more general<P>
|
||
|
isomorphic data structures (such as arrays), which is often desirable.<P>
|
||
|
<P>
|
||
|
This proposal deals only with changing the test which is used to<P>
|
||
|
determine whether two constants may be coalesced. Issue<P>
|
||
|
<A HREF="iss282.htm">QUOTE-SEMANTICS</A> deals with whether coalescing may be performed only by<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>, or by <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> and <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> as well. If proposal<P>
|
||
|
QUOTE-SEMANTICS:SAME-AS-COMPILE-FILE passes, then coalescing could be<P>
|
||
|
performed on all constants.<P>
|
||
|
<P>
|
||
|
This proposal uses the terms "source code", "compiled code", and<P>
|
||
|
"similar as constants" that are defined in proposal<P>
|
||
|
<A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES:SPECIFY</A>.<P>
|
||
|
<P>
|
||
|
The term "coalesce" is defined as follows. Suppose A and B are two<P>
|
||
|
objects used as quoted constants in the source code, and that A' and<P>
|
||
|
B' are the corresponding objects in the compiled code. If A' and B'<P>
|
||
|
are <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> but A and B were not <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A>, then we say that A and B have been<P>
|
||
|
coalesced by the compiler.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Proposal CONSTANT-COLLAPSING:GENERALIZE:<P>
|
||
|
</B><P>
|
||
|
State that an implementation is permitted to coalesce constants<P>
|
||
|
appearing in code to be compiled if and only if they are similar as<P>
|
||
|
constants, unless the objects involved are of type <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A>, <A REL=DEFINITION HREF="../Body/t_pkg.htm#package"><B>PACKAGE</B></A>,<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>STRUCTURE</B></A>, or <A REL=DEFINITION HREF="../Body/t_std_ob.htm#standard-object"><B>STANDARD-OBJECT</B></A>.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Rationale:<P>
|
||
|
</B><P>
|
||
|
There is little reason why implementations should not be allowed to<P>
|
||
|
perform more general collapsing of objects, since the arguments<P>
|
||
|
against doing so also apply to collapsing of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> objects, which<P>
|
||
|
is already permitted. The arguments for coalescing of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> data<P>
|
||
|
structures (primarily space reduction) also apply to coalescing of<P>
|
||
|
data structures that are equivalent under a more general coalescing<P>
|
||
|
predicate.<P>
|
||
|
<P>
|
||
|
Objects of type <A REL=DEFINITION HREF="../Body/t_symbol.htm#symbol"><B>SYMBOL</B></A> and <A REL=DEFINITION HREF="../Body/t_pkg.htm#package"><B>PACKAGE</B></A> cannot be coalesced because the fact<P>
|
||
|
that they are named, interned objects means they are already as<P>
|
||
|
coalesced as it is useful for them to be. Uninterned symbols could<P>
|
||
|
perhaps be coalesced, but that was thought to be more dangerous than<P>
|
||
|
useful. Objects of type <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>STRUCTURE</B></A> and <A REL=DEFINITION HREF="../Body/t_std_ob.htm#standard-object"><B>STANDARD-OBJECT</B></A> could be<P>
|
||
|
coalesced if a "similar as a constant" predicate were defined for them;<P>
|
||
|
it would be a generic function. Currently <A HREF="iss215.htm">LOAD-OBJECTS</A> only defines how<P>
|
||
|
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> and <A REL=DEFINITION HREF="../Body/f_load.htm#load"><B>LOAD</B></A> work together to construct an object in the<P>
|
||
|
compiled code that is equivalent to the object in the source code,<P>
|
||
|
and a different mechanism would have to be added to permit coalescence.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Current Practice:<P>
|
||
|
</B><P>
|
||
|
Both PSL/PCLS and A-Lisp collapse isomorphic arrays and structures,<P>
|
||
|
and certain other data types that are defined internally as structures<P>
|
||
|
(RANDOM-STATEs, for example). Lucid Common Lisp also uses a more<P>
|
||
|
general coalescing predicate than <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A>.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Cost to implementors:<P>
|
||
|
</B><P>
|
||
|
For implementations that currently coalesce based on <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> or that do<P>
|
||
|
no coalescing, there is no associated implementation cost.<P>
|
||
|
<P>
|
||
|
For implementations that currently coalesce things that this proposal<P>
|
||
|
forbids them to coalesce (such as STRUCTUREs or uninterned symbols),<P>
|
||
|
the implementation cost is probably small.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Cost to users:<P>
|
||
|
</B><P>
|
||
|
Programs that depend on objects not being coalesced except when they<P>
|
||
|
are <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> may break under this proposal. The only way one would be<P>
|
||
|
able to detect that coalescing has taken place is if objects that were<P>
|
||
|
not <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> in the source file become <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> after compilation; accessors on<P>
|
||
|
the objects would return the same values regardless of whether or not<P>
|
||
|
coalescing has taken place.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Benefits:<P>
|
||
|
</B><P>
|
||
|
Collapsing of isomorphic arrays may lead to significant memory savings<P>
|
||
|
in some applications.<P>
|
||
|
<P>
|
||
|
<P>
|
||
|
<B>Discussion:<P>
|
||
|
</B><P>
|
||
|
This proposal depends heavily on issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A>.<P>
|
||
|
<P>
|
||
|
Some people believe that if the definition of <A REL=DEFINITION HREF="../Body/f_equal.htm#equal"><B>EQUAL</B></A> weren't "broken",<P>
|
||
|
there wouldn't be any need for this proposal.<P>
|
||
|
<P>
|
||
|
There is no inherent reason why the "coalescing predicate" must be the<P>
|
||
|
same as the relationship used by the compiler/loader to construct<P>
|
||
|
equivalent copies of objects of constants, but making the same rules<P>
|
||
|
be applied in both situations simplifies the language somewhat.<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>
|