1
0
Fork 0
cl-sites/HyperSpec-7-0/HyperSpec/Issues/iss360_w.htm
2024-04-01 10:24:07 +02:00

177 lines
10 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 WITH-COMPILATION-UNIT 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/iss359_w.htm">
<LINK REL=UP HREF="../Issues/iss360.htm">
<LINK REL=NEXT HREF="../Issues/iss361_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/iss359_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss360.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss361_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
<HR>
<H2>Issue WITH-COMPILATION-UNIT Writeup</H2>
<PRE><B>Forum:</B> Compiler<P>
<B>Issue:</B> <A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A><P>
<B>References:</B> <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> (p438), <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> (p439)<P>
<B>Category:</B> ADDITION<P>
<B>Edit history:</B> 29-Sep-88, Version 1 by Pitman<P>
10-Mar-89, Version 2 by Pitman (merge comments)<P>
13-Mar-89, Version 3 by Loosemore (update discussion)<P>
10-Apr-89, Version 4 by Pitman (wording change per X3J13)<P>
<B>Status:</B> Ready for release<P>
<P>
<B>Problem Description:<P>
</B><P>
Some actions done by the compiler (and particularly the file compiler)<P>
are typically deferred until the &quot;very end&quot; of compilation. For example,<P>
some compilers complain about &quot;functions seen but not defined&quot;.<P>
<P>
Unfortunately, since <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> is the largest unit of granularity,<P>
and since systems often extend over more than one file, it often happens<P>
that the compiler needlessly complains at the end of compiling one file<P>
about the absence of functions defined in the next file. <P>
<P>
<B>Proposal (WITH-COMPILATION-UNIT:NEW-MACRO):<P>
</B><P>
Add the following new macro:<P>
<P>
<A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A> options <A REL=DEFINITION HREF="../Body/03_dd.htm#AMbody"><B>&amp;BODY</B></A> forms [Macro]<P>
<P>
Executes forms from left to right. Within the dynamic context<P>
of this form, warnings deferred by the compiler until &quot;the end of<P>
compilation&quot; will be deferred until the end of the outermost call<P>
to <A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A>. The result(s) are the same as that of<P>
the last of the FORMS (or <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if FORMS is null).<P>
<P>
OPTIONS is a keyword/value list, where only the values are<P>
evaluated. The set of keywords permitted may be extended by the<P>
implementation, but the only keyword defined by this <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> is:<P>
<P>
:OVERRIDE <A REL=DEFINITION HREF="../Body/t_ban.htm#boolean"><B>boolean</B></A><P>
<P>
The default is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>. If nested dynamically only the outer call<P>
to <A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A> has any effect unless <A REL=DEFINITION HREF="../Body/t_ban.htm#boolean"><B>BOOLEAN</B></A> is T,<P>
in which case warnings are deferred only to the end of the<P>
innermost call.<P>
<P>
It follows that the functions <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> and <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> should<P>
<A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> the effect of (<A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A> (:OVERRIDE <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A>) ...)<P>
around their code.<P>
<P>
Any implementation-dependent extensions may only be provided<P>
as the result of an explicit programmer request by use of <P>
an implementation-dependent keyword. Implementations are forbidden<P>
from attaching additional meaning to a conforming use of this<P>
macro.<P>
<P>
Note also that not all warnings are deferred. In some implementations,<P>
it may be that none are deferred. This proposal only creates an<P>
interface to the capability where it exists, it does not <A REL=DEFINITION HREF="../Body/f_provid.htm#require"><B>require</B></A> the<P>
creation of the capability. An implementation which does not do <P>
deferred warnings may correctly implement this as expanding into <A REL=DEFINITION HREF="../Body/s_progn.htm#progn"><B>PROGN</B></A>.<P>
<P>
<B>Test Case:<P>
</B><P>
(<A REL=DEFINITION HREF="../Body/m_defun.htm#defun"><B>DEFUN</B></A> COMPILE-FILES (<A REL=DEFINITION HREF="../Body/03_da.htm#AMrest"><B>&amp;REST</B></A> FILES)<P>
(<A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A> ()<P>
(<A REL=DEFINITION HREF="../Body/f_mapc_.htm#mapcar"><B>MAPCAR</B></A> #'(<A REL=DEFINITION HREF="../Body/a_lambda.htm#lambda"><B>LAMBDA</B></A> (FILE) (<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> FILE)) FILES)))<P>
<P>
(COMPILE-FILES &quot;A&quot; &quot;B&quot; &quot;C&quot;)<P>
<P>
processes deferred warnings only after compiling all of A, B, and C.<P>
<P>
<B>Rationale:<P>
</B><P>
This will make the development of portable system-construction tools<P>
considerably more convenient. <P>
<P>
<B>Current Practice:<P>
</B><P>
Lucid has a very similar facility, called WITH-DEFERRED-WARNINGS.<P>
<P>
TI Explorer and Symbolics Genera have a similar facility, which they<P>
call COMPILER-WARNING-CONTEXT-BIND.<P>
<P>
<B>Cost to Implementors:<P>
</B><P>
In implementations which have no deferred warnings, there is no cost.<P>
<P>
In implementations which have deferred warnings, the cost is probably<P>
fairly small -- usually just a matter of writing interfacing the <P>
proposed macro to an existing one.<P>
<P>
<B>Cost to Users:<P>
</B><P>
None. This is a compatible addition.<P>
<P>
<B>Cost of Non-Adoption:<P>
</B><P>
Portable system-construction tools would continue to print lots of<P>
spurious warnings because they would have no way to tell the system<P>
that a set of files was working together.<P>
<P>
<B>Benefits:<P>
</B><P>
The cost of non-adoption is avoided.<P>
<P>
<B>Aesthetics:<P>
</B><P>
The ability to create a compilation unit other than a file is important.<P>
<P>
<B>Discussion:<P>
</B><P>
Pitman and Benson support this addition.<P>
<P>
One could imagine adding more options at a later date.<P>
<P>
It was the opinion of the compiler committee that there was room for<P>
expansion here to address issues like bounding the scope of global<P>
proclamations, sharing compile-time environments across files, etc.<P>
However, insufficient work was done on this to justify putting such<P>
a thing into the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A>. The only clear need we have at this time<P>
was to defer warnings, but we chose a general name like <P>
<A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>WITH-COMPILATION-UNIT</B></A> rather than a specific name like Lucid's<P>
WITH-DEFERRED-WARNINGS in order to encourage implementations to <P>
experiment with other kinds of options under implementation-specific<P>
keywords. Perhaps by the time of the next <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> there will be<P>
sufficient understanding of this area to warrant further elaboration<P>
of this primitive.<P>
<P>
Kim Barrett says:<P>
<P>
I strongly oppose the behavior you proposed for compile and<P>
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>compile-file</B></A>. It is my belief that whether to override or not must be<P>
controlled through an argument to the compile functions, with the<P>
default being to override. Otherwise, all existing code which makes<P>
use of the compile functions must be modified to protect itself by<P>
wrapping a (<A REL=DEFINITION HREF="../Body/m_w_comp.htm#with-compilation-unit"><B>with-compilation-unit</B></A> (:override t) ...) around the calls<P>
to the compiler.<P>
<P>
Consider a stream system built on an object system which will compose<P>
and compile functions on the fly on an as needed basis. It would be<P>
very strange for the functions so generated while doing file io for<P>
the user's <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>compile-file</B></A> to have any relationship with said<P>
<A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>compile-file</B></A>.<P>
<P>
I agree with your position that implementation-dependent extensions<P>
must be explicitly requested.<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>