[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Need for (declare (ignorable ...))
- To: Jonathan A Rees <JAR@MC.LCS.MIT.EDU>
- Subject: Need for (declare (ignorable ...))
- From: Skef Wholey <Wholey@C.CS.CMU.EDU>
- Date: Fri, 07 Mar 1986 17:40:00 -0000
- Cc: common-lisp@SU-AI.ARPA
- In-reply-to: Msg of 7 Mar 1986 13:05-EST from Jonathan A Rees <JAR at MC.LCS.MIT.EDU>
- Sender: WHOLEY@C.CS.CMU.EDU
Date: Friday, 7 March 1986 13:05-EST
From: Jonathan A Rees <JAR at MC.LCS.MIT.EDU>
Re: Need for (declare (ignorable ...))
Common Lisp (and in fact, every language that has variables) needs a
(DECLARE (IGNORABLE ...)) in addition to (DECLARE (IGNORE ...)). The
meaning of (DECLARE (IGNORABLE X)) is: the variable X might or might not
be used, and I don't want the compiler to generate a warning in either
Have other people suffered from this lack, or do I just write
particularly perverse macros?
I think the problem is widespread enough to warrant something with the effect
of that declaration. A change like this will probably take years to become
"real Common Lisp," but there are other ways around this.
One writer of system code in the Spice Lisp system ran into this problem, and
just added references to the "ignorable" variables right after their binding.
When we switched to a new compiler, which was smarter in a number of ways,
warnings were generated because the referenced-p slot of the variable's
compiler data structure wasn't set when the variable reference could be
optimized away. By lobbying hard, I was able to convince the compiler writer
(Scott Fahlman), that the right thing to do IS to count that reference, since
dummy references are the only way to supress warnings in such cases, AND
since optimization is the compiler's business, references should be counted as
they are written, not as they appear in code. For instance, generating a
warning that an index variable is not referenced after the compiler has
unrolled a loop would be truly asinine.
So, I would suggest that Common Lisp compilers treat all references equally in
this respect, even though some may be optimized away. Then writers of hairy
macros can insert references to these variables and be sure of getting only
Side note: Most "portable" Common Lisp code I've had to deal with generates all
kinds of warnings when compiled. It's not clear if this is because different
implementations warn about different things or if the code needs ignore
declarations, or whatever, but it would be nice if people would try to make
such code compile without warnings before inviting other people to use it.