[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Issue: PROCLAIM-LEXICAL



    Date: Sat, 2 May 1987  16:13 EDT
    From: Scott E. Fahlman <Fahlman at C.CS.CMU.EDU>

    Not true.  You can suppress this warning by saying (proclaim '(special
    <var>)) or (defvar <var>).

*Not* not true!  Look again at the example.  If you declare the variable
special, you will change the semantics of the program.  In this example
you would also have to rename every X that's lexically bound; being an
extremely non-local transformation, this is unacceptable.

    In my view (the manual doesn't spell this out, so we rely on shared
    culture) a Common Lisp compiler is free to issue a warning any time it
    spots anything suspicious, even though the code may be legal.

I basically agree with this, but you should note that every other sort
of warning is avoidable.  E.g. an unreferenced bound variable is often a
result of a program error, but when it's not it can be dealt with by
(DECLARE (IGNORE ...)); an OR with only one subform can be a symptom of
a misplaced parenthesis, but where it's the right thing there are ways
to get around the problem (make your macros smarter...).  But in this
case the only way to get rid of the warning is either by
alpha-converting or by making the program possibly incorrect, which is
definitely unfriendly.

I don't know how you develop code, but I like to get my programs into
a condition where they do not elicit warnings from the compiler.

    The use of an undeclared variable is
    legal because users like to do this in the interpreter; in a code file,
    on the other hand, it is either very unstylish or, more likely, the
    result of a typo.  

Why is this any different from an undefined function, which is not
similarly warned about?  I believe these two situations (forward
reference to a variable and to a function) should be treated
symmetrically.

    If a fix really is needed here, it should probably be a compiler
    declaration that suppresses all warnings in a certain stretch of code.

Unacceptable in this case (unless we adopt BY-THE-BOOK); many warnings
are quite desirable.  I would say a warning is OK if either it indicates
that an error will happen at run time, or if the code is truly is dubious
style AND there is an easy way to fix or annotate the code so that the
warning goes away.

    As a separate issue, we might want to try to hammer out a proposal for
    what people have called "global lexicals", and we might even want to
    make this the default for undeclared symbols used free.

If you look at the proposal carefully you'll see that it contains
exactly this; namely, in the GENERAL and RESTRICTED alternatives, you
can do (PROCLAIM '(LEXICAL ...)).  I'm wondering how you missed it,
although if you only looked at the summary at the top and not the rest
of the message, that would explain it; the introduction is admittedly
misleading.  I'll fix that next time around.

Like I said in the "Status:" line, this is very preliminary.

Jonathan