1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss079_w.htm

221 lines
12 KiB
HTML
Raw Normal View History

2024-04-01 10:24:07 +02:00
<!-- 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-CIRCULAR-COMPILATION 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/iss078_w.htm">
<LINK REL=UP HREF="../Issues/iss079.htm">
<LINK REL=NEXT HREF="../Issues/iss080_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/iss078_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss079.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss080_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CONSTANT-CIRCULAR-COMPILATION Writeup</H2>
<PRE>Option YES passed 17-0-1 at meeting of Mar-89.<P>
-----<P>
<B>Forum:</B> Compiler<P>
<B>Issue:</B> <A HREF="iss079.htm">CONSTANT-CIRCULAR-COMPILATION</A><P>
<B>References:</B> Issue <A HREF="iss080.htm">CONSTANT-COLLAPSING</A><P>
Issue <A HREF="iss282.htm">QUOTE-SEMANTICS</A><P>
<B>Category:</B> CLARIFICATION, ADDITION<P>
<B>Edit History:</B> V1, 07 Nov 1988, Sandra Loosemore<P>
V2, 14 Nov 1988, Cris Perdue<P>
V3, 12 Dec 1988, Sandra Loosemore (merge versions 1 and 2)<P>
V4, 03 Jan 1989, Sandra Loosemore (add PRESERVE-SHARING-ONLY)<P>
V5, 06 Jan 1989, Sandra Loosemore (minor wording changes)<P>
V6, 08 Feb 1989, Sandra Loosemore (replace FLAG with YES)<P>
V7, 11 Mar 1989, Sandra Loosemore (error terminology)<P>
V8, 18 Mar 1989, Sandra Loosemore (changes per Moon, Masinter)<P>
<B>Status:</B> Ready for release<P>
<P>
<P>
<B>Problem Description:<P>
</B><P>
CLtL does not specify whether constants containing circular or<P>
recursive references may be compiled. It is also not clear whether<P>
the compiler must preserve sharing of <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> substructures; that is, whether<P>
subobjects that are <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> in the source code must remain <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> after being<P>
compiled.<P>
<P>
The proposals below apply to constants appearing in a file compiled by<P>
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>. If proposal QUOTE-SEMANTICS:SAME-AS-COMPILE-FILE<P>
passes, then the same constraints would apply to all constants. The<P>
minimal scope over which sharing would be required to be detected is<P>
over a single call to <A REL=DEFINITION HREF="../Body/f_eval.htm#eval"><B>EVAL</B></A> or <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A>.<P>
<P>
In the proposals that follow, &quot;preserving EQLness&quot; means that<P>
subobjects that are <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> in the source code must remain <A REL=DEFINITION HREF="../Body/a_eql.htm#eql"><B>EQL</B></A> after being<P>
compiled; that is, things don't get &quot;less EQL&quot; after compilation.<P>
(Note that coalescing of constants implies that things may <A REL=DEFINITION HREF="../Body/f_get.htm#get"><B>get</B></A> &quot;more<P>
EQL&quot;.)<P>
<P>
<P>
Proposal CONSTANT-CIRCULAR-COMPILATION:NO<P>
<P>
State that conforming programs must not contain circular objects<P>
appearing as constants to be compiled. The consequences of compiling<P>
a program containing such an object with <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> and/or LOADing<P>
the output produced by <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> for such a program [and, if we<P>
accept proposal QUOTE-SEMANTICS:SAME-AS-COMPILE-FILE, compiling it<P>
with <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> or evaluating it interpretively] are undefined.<P>
<P>
State that the compiler is not required to preserve EQLness of<P>
substructures.<P>
<P>
Rationale:<P>
<P>
This proposal would not <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> any existing implementation to change.<P>
<P>
Disallowing portable programs from containing circular constants<P>
allows compiled file loaders to use somewhat simpler implementation<P>
strategies (for example, to build constants in a strict bottom-up<P>
fashion).<P>
<P>
<P>
Proposal CONSTANT-CIRCULAR-COMPILATION:PRESERVE-SHARING-ONLY<P>
<P>
State that conforming programs must not contain circular objects<P>
appearing as constants to be compiled. The consequences of compiling<P>
a program containing such an object with <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> and/or LOADing<P>
the output produced by <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> for such a program [and, if we<P>
accept proposal QUOTE-SEMANTICS:SAME-AS-COMPILE-FILE, compiling it<P>
with <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> or evaluating it interpretively] are undefined.<P>
<P>
State that the compiler is required to preserve EQLness of<P>
substructures within a file compiled with <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>.<P>
<P>
Rationale:<P>
<P>
Disallowing portable programs from containing circular constants<P>
allows compiled file loaders to use somewhat simpler implementation<P>
strategies (for example, to build constants in a strict bottom-up<P>
fashion).<P>
<P>
Some programs (such as PCL) have come to depend on <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> <P>
preserving the EQLness of uninterned symbols, and it is cleaner<P>
to <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> sharing to be preserved in general instead of making<P>
symbols be a special case. Requiring sharing to be preserved still<P>
allows loaders to build constants bottom-up.<P>
<P>
<P>
Proposal <A HREF="iss079.htm">CONSTANT-CIRCULAR-COMPILATION:YES</A><P>
<P>
State that objects containing circular references may legitimately<P>
appear as constants to be compiled. State that the compiler is<P>
required to preserve EQLness of substructures within a file compiled<P>
with <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>.<P>
<P>
Rationale:<P>
<P>
Users seem to expect this functionality, and some implementations <P>
already <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> it.<P>
<P>
<P>
<B>Current Practice:<P>
</B><P>
A-Lisp preserves EQLness of substructures (since it makes an effort to<P>
collapse isomorphic structures) but signals an error if an attempt is<P>
made to compile a circular constant. PSL and Utah Common Lisp both<P>
get stuck in an infinite loop if an attempt is made to compile a<P>
reentrant <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A>. The TI Explorer compiler is able to reproduce<P>
recursive lists and arrays, but currently hangs in a loop on a<P>
circular list. Neither the Explorer nor Symbolics Genera 7.x detects<P>
EQLness of list CDRs. Lucid handles circular constants correctly.<P>
Franz uses a flag to control whether or not to attempt to detect<P>
circular constants. KCL handles circular structures, but only detects<P>
sharing of top-level <A REL=DEFINITION HREF="../Body/f_docume.htm#structure"><B>structure</B></A> (it does not traverse constants to look<P>
for shared substructure).<P>
<P>
<P>
<B>Cost to implementors:<P>
</B><P>
We know of no implementation that would have to change under proposal<P>
NO. <P>
<P>
For proposal YES, some implementations would <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> sweeping<P>
changes; in some cases a completely different dumper/loader strategy<P>
would have to be implemented.<P>
<P>
The cost of proposal PRESERVE-SHARING-ONLY would fall somewhere in<P>
between.<P>
<P>
<P>
<B>Cost to users:<P>
</B><P>
The situation now is that programs which depend upon circularity or<P>
sharing of substructure being preserved by the compiler are already<P>
nonportable. Proposal NO simply formalizes the status quo. Proposal<P>
YES would offer users functionality that is currently not portable.<P>
<P>
Portable CommonLoops reportedly requires EQLness of uninterned symbols<P>
to be preserved across a file, and would break under proposal NO.<P>
According to Cris Perdue:<P>
<P>
I am told that support for PCL requires the kinds of guarantees about<P>
uninterned symbols [that say EQLness will be preserved]. Jim Kempf<P>
here at Sun tells me he believes that this is true. John Foderaro<P>
said that Franz made their compiler give this behavior in order to<P>
support PCL.<P>
<P>
Jim Kempf says he believes that certain GENSYMs appear in multiple<P>
pieces of initialization code across a file in PCL, and the<P>
initialization code only works if symbols <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> at compile time map to<P>
symbols that are <A REL=DEFINITION HREF="../Body/f_eq.htm#eq"><B>EQ</B></A> at load time.<P>
<P>
<P>
<B>Benefits:<P>
</B><P>
An area of ambiguity in the language is removed.<P>
<P>
<P>
<B>Discussion:<P>
</B><P>
The issue of compiler speed is largely a red herring on this issue;<P>
the overhead of detecting circularities is generally quite small. The<P>
main question is whether we should <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> some implementations to<P>
completely redo their compiler/loader interface in order to support<P>
circular constants. <P>
<P>
It has been argued that any &quot;serious&quot; implementation will support<P>
circular constants anyway, because of customer demand. However, since<P>
there appears to be only one implementation (Lucid) that now<P>
implements proposal YES in its full generality, perhaps the demand for<P>
this feature is not really all that strong.<P>
<P>
Earlier drafts of this writeup contained a proposal FLAG which would<P>
have added a variable *COMPILE-CIRCLE*, similar to <A REL=DEFINITION HREF="../Body/v_pr_cir.htm#STprint-circleST"><B>*PRINT-CIRCLE*</B></A>.<P>
However, there were unresolved problems about what would happen if the<P>
value of this variable were altered within the file being compiled,<P>
and it was generally agreed that this proposal didn't have any<P>
particular advantages over proposal YES and just introduced<P>
unnecessary hairiness.<P>
<P>
Since it is usually fairly simple to detect circular constants,<P>
Loosemore would support an amendment to proposals NO and<P>
PRESERVE-SHARING-ONLY to change the word &quot;undefined&quot; to &quot;unspecified&quot;,<P>
adding:<P>
<P>
Implementations must either correctly handle the circular reference<P>
or signal an error. <P>
<P>
This is similar to the language which is already used in proposal<P>
<A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES:SPECIFY</A>.<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>