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

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
case.

There is no way to simulate this feature in Common Lisp.  If there is no
such declaration, and X isn't used, then I get a warning message X bound
but not used; if I use (DECLARE (IGNORE X)), and X is used, then I get a
warning message saying that X was declared ignored but in fact was used.
I wouldn't want to change either of these features of Common Lisp
compilers.

The IGNORABLE declaration is needed for applications where code is
automatically generated, say, by a macro or a compiler.  A macro,
especially, is not in a good position to know whether a variable is
being referenced.  A sledgehammer like a code traversal tool shouldn't
be required for this simple application.  It has been in T (Yale Scheme)
since 1981, and has proved very useful.

Have other people suffered from this lack, or do I just write
particularly perverse macros?

Jonathan Rees