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

143 lines
6.8 KiB
HTML
Raw Permalink 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-FUNCTION-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/iss081_w.htm">
<LINK REL=UP HREF="../Issues/iss082.htm">
<LINK REL=NEXT HREF="../Issues/iss083_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/iss081_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss082.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss083_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue CONSTANT-FUNCTION-COMPILATION Writeup</H2>
<PRE><B>Forum:</B> Compiler<P>
<B>Issue:</B> <A HREF="iss082.htm">CONSTANT-FUNCTION-COMPILATION</A><P>
<B>References:</B> Issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A><P>
<B>Category:</B> CLARIFICATION<P>
<B>Edit History:</B> V1, 22 Mar 1989, Sandra Loosemore (split from issue<P>
<A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A>)<P>
<B>Status:</B> **DRAFT**<P>
<P>
<P>
<B>Problem Description:<P>
</B><P>
Can objects of type <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A> (or some subset of FUNCTIONs) appear as<P>
quoted or self-evaluating constants in compiled code? <P>
<P>
There are two questions that must be answered:<P>
<P>
- How does one test whether a particular function is a member of the<P>
subset of functions that are dumpable?<P>
<P>
- For those functions that are dumpable, how do <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><P>
arrange for an &quot;equivalent&quot; copy of the function in the source code to<P>
be created in the compiled code?<P>
<P>
This writeup uses terminology from issue CONSTANT-COMPILABLE-TYPES:<P>
&quot;source code&quot;, &quot;compiled code&quot;, and &quot;similar as constants&quot;.<P>
<P>
<P>
<B>Proposal CONSTANT-FUNCTION-COMPILATION:NO:<P>
</B><P>
Objects of type <A REL=DEFINITION HREF="../Body/a_fn.htm#function"><B>FUNCTION</B></A> are not supported in compiled constants.<P>
<P>
Rationale:<P>
<P>
Nobody has been able to come up with a well-defined specification of<P>
how the compiler and loader would be required to reconstruct<P>
function constants that would work for all functions.<P>
<P>
Nobody has been able to come up with a well-defined specification of<P>
some subset of functions that could be dumped.<P>
<P>
<P>
<B>Current Practice:<P>
</B><P>
Coral can dump compiled functions, but not foreign functions.<P>
<P>
The TI Explorer cannot dump closures (either compiled or evaluated),<P>
but can dump non-closure compiled functions.<P>
<P>
Symbolics Genera can't dump closures either.<P>
<P>
Kyoto Common Lisp can't dump any functions.<P>
<P>
<P>
<B>Cost to implementors:<P>
</B><P>
None. Implementations that can dump (some subset of) functions may<P>
continue to do so, since issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A> permits<P>
implementations to extend the notion of &quot;similar as constants&quot;.<P>
<P>
<P>
<B>Cost to users:<P>
</B><P>
None. Programs that depend on being able to dump functions are<P>
already nonportable, since not all implementations can dump all<P>
functions and there is no portable way to construct or test for<P>
functions that are dumpable in those implementations.<P>
<P>
<P>
<B>Benefits:<P>
</B><P>
Users will know what to (or what not to) expect when using functions<P>
in compiled constants.<P>
<P>
<P>
<B>Discussion:<P>
</B><P>
This issue was split from issue <A HREF="iss081.htm">CONSTANT-COMPILABLE-TYPES</A> because it<P>
appeared to be controversial enough to merit separate discussion.<P>
<P>
Cris Perdue originally suggested:<P>
<P>
Only function constants that are not compiled-functions and do not<P>
close over any (lexical) variables are supported in compiled<P>
constants.<P>
<P>
Two such functions are similar as constants if their<P>
SOURCE-LAMBDA-EXPRESSIONs are similar as constants.<P>
<P>
Dick Gabriel responded:<P>
<P>
I guess I pretty strongly object to leaving functions out of the list<P>
of constants that can appear in compiled code. The part that's<P>
disturbing is that such non-Lispy things like arrays, hashtables, and<P>
pathnames get better treatment than functions, the most Lispy part of<P>
Common Lisp. I wonder how many implementations will be forced to come<P>
within an inch of the required functionality to implement a first-rate<P>
CLOS?<P>
<P>
The specification of the subset of functions that are acceptable as<P>
compiled constants cannot be tested for within Common Lisp itself.<P>
<P>
I suggest we ask implementors (Lucid included) to bite the bullet and<P>
handle this case correctly. Won't our grandchildren appreciate us<P>
treating Common Lisp like Lisp and not like PASCAL?<P>
<P>
If we were to specify that all functions could appear as constants, we<P>
would also need to clarify whether the closed-over variable bindings<P>
become immutable, and also deal with whether bindings that are closed<P>
over more than one function retain their uniqueness. Also, the cost<P>
to implementors to add support for dumping non-interpreted functions<P>
may be quite high.<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>