229 lines
14 KiB
HTML
229 lines
14 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 COMPILER-DIAGNOSTICS 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/iss064_w.htm">
|
|
<LINK REL=UP HREF="../Issues/iss065.htm">
|
|
<LINK REL=NEXT HREF="../Issues/iss066_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/iss064_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Previous]" SRC="../Graphics/Prev.gif" ALIGN=Bottom></A><A REL=UP HREF="../Issues/iss065.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Up]" SRC="../Graphics/Up.gif" ALIGN=Bottom></A><A REL=NEXT HREF="../Issues/iss066_w.htm"><IMG WIDTH=40 HEIGHT=40 ALT="[Next]" SRC="../Graphics/Next.gif" ALIGN=Bottom></A></H1>
|
|
|
|
<HR>
|
|
|
|
|
|
|
|
<H2>Issue COMPILER-DIAGNOSTICS Writeup</H2>
|
|
|
|
<PRE><B>Forum:</B> Compiler<P>
|
|
<B>Issue:</B> <A HREF="iss065.htm">COMPILER-DIAGNOSTICS</A><P>
|
|
<B>References:</B> CLtL p. 438-439, 62, 69, 160, 161<P>
|
|
Condition System, Revision #18<P>
|
|
S:>KMP>cl-conditions.text.34<P>
|
|
Issue GC-MESSAGES<P>
|
|
Issue <A HREF="iss299.htm">RETURN-VALUES-UNSPECIFIED</A><P>
|
|
Issue <A HREF="iss067.htm">COMPILER-VERBOSITY</A><P>
|
|
Issue <A HREF="iss075_m.htm">CONDITION-RESTARTS</A><P>
|
|
<B>Category:</B> CLARIFICATION, ENHANCEMENT<P>
|
|
<B>Edit History:</B> V1, 15 Oct 1988, Sandra Loosemore<P>
|
|
V2, 19 Oct 1988, Sandra Loosemore (minor fixes)<P>
|
|
V3, 25 Oct 1988, Sandra Loosemore (input from Pitman & Gray)<P>
|
|
V4, 01 Nov 1988, Sandra Loosemore (fix typos)<P>
|
|
V5, 15 Dec 1988, Dan L. Pierson (new condition types)<P>
|
|
V6, 15 Dec 1988, Sandra Loosemore (additions, fix wording)<P>
|
|
V7, 16 Dec 1988, Dan L. Pierson (minor cleanup)<P>
|
|
V8, 07 Jan 1989, Sandra Loosemore (expand discussion)<P>
|
|
V9, 26 Jan 1989, Sandra Loosemore (simplify)<P>
|
|
V10, 22 Mar 1989, Sandra Loosemore (error terminology)<P>
|
|
V11, 11 Apr 1989, Kent Pitman (changes per X3J13)<P>
|
|
V12, 21-Jun-89, Moon (changes to point 4 only: return a<P>
|
|
status value from <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> also, make the status<P>
|
|
value <A REL=DEFINITION HREF="../Body/f_provid.htm#provide"><B>provide</B></A> more detail)<P>
|
|
V13, 22-Jun-89, Loosemore (fix one of the fixes)<P>
|
|
V14, 04-Jul-89, Loosemore (amendments from June meeting)<P>
|
|
<B>Status:</B> Passed V11 March 89<P>
|
|
Passed V14 June 89<P>
|
|
<P>
|
|
<B>Problem Description:<P>
|
|
</B><P>
|
|
It is unclear whether various diagnostics issued by the compiler are <P>
|
|
supposed to be true errors and warnings, or merely messages.<P>
|
|
<P>
|
|
In some implementations, <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> handles even serious error<P>
|
|
situations (such as syntax errors) by printing a message and then<P>
|
|
trying to recover and continue compiling the rest of the file, rather<P>
|
|
than by signalling an error. While this user interface style is just<P>
|
|
as acceptable as invoking the debugger, it means that a normal return<P>
|
|
from <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> does not necessarily imply that the file was<P>
|
|
successfully compiled.<P>
|
|
<P>
|
|
Many compilers issue warnings about programming style issues (such as<P>
|
|
binding a variable that is never used but not declared <A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A>).<P>
|
|
Sometimes these messages obscure warnings about more serious problems,<P>
|
|
and there should be some way to differentiate between the two. For<P>
|
|
example, it should be possible to suppress the style warnings.<P>
|
|
<P>
|
|
Also, neither CLtL nor issue <A HREF="iss299.htm">RETURN-VALUES-UNSPECIFIED</A> states what the <P>
|
|
return value from <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> should be.<P>
|
|
<P>
|
|
<P>
|
|
<B>Proposal COMPILER-DIAGNOSTICS:USE-HANDLER:<P>
|
|
</B><P>
|
|
(1) Introduce a new condition type, <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A>, which is a subtype<P>
|
|
of <A REL=DEFINITION HREF="../Body/e_warnin.htm#warning"><B>WARNING</B></A>.<P>
|
|
<P>
|
|
(2) Clarify that <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> and <A REL=DEFINITION HREF="../Body/e_warnin.htm#warning"><B>WARNING</B></A> conditions may be signalled within <P>
|
|
<A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> or <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A>, including arbitrary errors which may <P>
|
|
occur due to compile-time processing of (<A REL=DEFINITION HREF="../Body/s_eval_w.htm#eval-when"><B>EVAL-WHEN</B></A> (<A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A>) ...) <P>
|
|
forms or macro expansion.<P>
|
|
<P>
|
|
Considering only those conditions signalled -by- the compiler (as<P>
|
|
opposed to -within- the compiler),<P>
|
|
<P>
|
|
(a) Conditions of type <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> may be signalled by the compiler in<P>
|
|
situations where the compilation cannot proceed without<P>
|
|
intervention.<P>
|
|
<P>
|
|
Examples:<P>
|
|
file open errors<P>
|
|
syntax errors<P>
|
|
<P>
|
|
(b) Conditions of type <A REL=DEFINITION HREF="../Body/e_warnin.htm#warning"><B>WARNING</B></A> may be signalled by the compiler in <P>
|
|
situations where the <A REL=DEFINITION HREF="../Body/07_ffb.htm#standard"><B>standard</B></A> explicitly states that a warning must,<P>
|
|
should, or may be signalled; and where the compiler can determine <P>
|
|
that a situation with undefined consequences or that would cause<P>
|
|
an error to be signalled would result at runtime.<P>
|
|
<P>
|
|
Examples:<P>
|
|
violation of type declarations<P>
|
|
<A REL=DEFINITION HREF="../Body/s_setq.htm#setq"><B>SETQ</B></A>'ing or rebinding a constant defined with <A REL=DEFINITION HREF="../Body/m_defcon.htm#defconstant"><B>DEFCONSTANT</B></A><P>
|
|
calls to built-in Lisp functions with wrong number of arguments<P>
|
|
or malformed keyword argument lists<P>
|
|
referencing a variable declared <A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A><P>
|
|
unrecognized declaration specifiers<P>
|
|
<P>
|
|
(c) The compiler is permitted to signal diagnostics about matters of<P>
|
|
programming style as conditions of type <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A>. Although <P>
|
|
STYLE-WARNINGs -may- be signalled in these situations, no <P>
|
|
implementation is -required- to do so. However, if an <P>
|
|
implementation does choose to signal a condition, that condition <P>
|
|
will be of type <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A> and will be signalled by a call to <P>
|
|
the function <A REL=DEFINITION HREF="../Body/f_warn.htm#warn"><B>WARN</B></A>.<P>
|
|
<P>
|
|
Examples:<P>
|
|
redefinition of function with different argument list<P>
|
|
calls to function with wrong number of arguments<P>
|
|
unreferenced local variables not declared <A REL=DEFINITION HREF="../Body/d_ignore.htm#ignore"><B>IGNORE</B></A><P>
|
|
declaration specifiers described in CLtL but ignored by <P>
|
|
the compiler<P>
|
|
<P>
|
|
(3) State that both <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> are permitted (but not<P>
|
|
required) to establish a handler for <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A>. For example, they<P>
|
|
might issue a warning, and restart compilation from some<P>
|
|
implementation-dependent point in order to let the compilation<P>
|
|
proceed without manual intervention.<P>
|
|
<P>
|
|
(4) Specify that <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> return three values. The first<P>
|
|
value from <A REL=DEFINITION HREF="../Body/f_cmp.htm#compile"><B>COMPILE</B></A> is not changed by this proposal. The first value<P>
|
|
from <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> is the <A REL=DEFINITION HREF="../Body/f_tn.htm#truename"><B>truename</B></A> of the output file, or <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if the <P>
|
|
file could not be created.<P>
|
|
<P>
|
|
The second value is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if no compiler diagnostics were issued, and<P>
|
|
true otherwise.<P>
|
|
<P>
|
|
The third value is <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if no compiler diagnostics other than style<P>
|
|
warnings were issued. A non-NIL value indicates that there were <P>
|
|
"serious" compiler diagnostics issued, or that other conditions of<P>
|
|
type <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> or <A REL=DEFINITION HREF="../Body/e_warnin.htm#warning"><B>WARNING</B></A> (but not <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A>) were signalled during<P>
|
|
compilation.<P>
|
|
<P>
|
|
<P>
|
|
<B>Rationale:<P>
|
|
</B><P>
|
|
Introducing the <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A> condition allows handlers to distinguish<P>
|
|
between potentially serious problems and mere kibitzing on the part of<P>
|
|
the compiler.<P>
|
|
<P>
|
|
The second and third return values from <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> give<P>
|
|
some indication of whether there were serious problems encountered in<P>
|
|
compiling the file.<P>
|
|
<P>
|
|
<P>
|
|
<B>Current Practice:<P>
|
|
</B><P>
|
|
No implementation behaves exactly as specified in this proposal.<P>
|
|
<P>
|
|
In VaxLisp, <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> handles most compile-time errors without<P>
|
|
invoking the debugger. (It gives up on that top-level form and moves on<P>
|
|
to the next one.) Instead of signalling errors or warnings, it simply<P>
|
|
prints them out as messages.<P>
|
|
<P>
|
|
In Lucid Common Lisp, <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> invokes the debugger when it encounters<P>
|
|
serious problems. <A REL=DEFINITION HREF="../Body/f_cmp_fi.htm#compile-file"><B>COMPILE-FILE</B></A> returns the <A REL=DEFINITION HREF="../Body/a_pn.htm#pathname"><B>pathname</B></A> for the output file.<P>
|
|
<P>
|
|
Symbolics Genera usually tries to keep compiling when it encounters errors;<P>
|
|
so does Symbolics Cloe.<P>
|
|
<P>
|
|
On the TI Explorer, the compiler tries to catch most errors and turn<P>
|
|
them into warnings (except for errors on opening a file), but the user<P>
|
|
can change special variable COMPILER:WARN-ON-ERRORS to <A REL=DEFINITION HREF="../Body/a_nil.htm#nil"><B>NIL</B></A> if he wants<P>
|
|
to enter the debugger on an error signalled during reading, macro<P>
|
|
expansion, or compile-time evaluation. The true name of the output<P>
|
|
file is returned as the first value. A second value indicates whether<P>
|
|
any errors or warnings were reported.<P>
|
|
<P>
|
|
IIM Common Lisp's compiler handles errors using a resignalling mechanism<P>
|
|
similar to what is described here.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to implementors:<P>
|
|
</B><P>
|
|
The cost to implementors is not trivial but not particularly high. This<P>
|
|
proposal tries to allow implementations considerable freedom in what<P>
|
|
kinds of conditions the compiler must detect and how they are handled,<P>
|
|
while still allowing users some reasonably portable ways to deal with<P>
|
|
compile-time errors.<P>
|
|
<P>
|
|
<P>
|
|
<B>Cost to users:<P>
|
|
</B><P>
|
|
This is a compatible extension. This proposal may cause users to see<P>
|
|
some small differences in the user interface to the compiler, but<P>
|
|
implementations already vary quite widely in their approaches. Some<P>
|
|
users will probably have to make some minor changes to their code.<P>
|
|
<P>
|
|
Adding the <A REL=DEFINITION HREF="../Body/e_style_.htm#style-warning"><B>STYLE-WARNING</B></A> type may cause conflicts with programs<P>
|
|
already using that name.<P>
|
|
<P>
|
|
<P>
|
|
<B>Benefits:<P>
|
|
</B><P>
|
|
Users are given a way to detect and handle compilation errors, which<P>
|
|
would simplify the implementation of portable code-maintenance<P>
|
|
utilities. The behavior of the compiler in error situations is made<P>
|
|
more uniform across implementations.<P>
|
|
<P>
|
|
<P>
|
|
<B>Discussion:<P>
|
|
</B><P>
|
|
The issue of whether the compiler may print normal progress messages<P>
|
|
is discussed in detail in a separate issue, <A HREF="iss067.htm">COMPILER-VERBOSITY</A>.<P>
|
|
<P>
|
|
Explicit calls to <A REL=DEFINITION HREF="../Body/a_error.htm#error"><B>ERROR</B></A> don't really justify warnings to be signalled<P>
|
|
at compile-time, but we assume implementors have some common sense<P>
|
|
about when it's appropriate to do so.<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>
|