From: Rainer Joswig
Subject: Warnings?
Date: 
Message-ID: <joswig-1807980143360001@194.163.195.67>
Given a function:

(defun baz ()
  *foo*
  *bar*)

Should the compiler warn that *foo* is not being used?

From: Jrm
Subject: Re: Warnings?
Date: 
Message-ID: <6ooumb$4pn$1@nntp1.ba.best.com>
I've worked with Lisps in which this is actually  the
way to fool the compiler into thinking that you have
`used' the variable (and thus supress unused variable
warnings.)

Rainer Joswig wrote in message ...
>Given a function:
>
>(defun baz ()
>  *foo*
>  *bar*)
>
>Should the compiler warn that *foo* is not being used?
From: Kent M Pitman
Subject: Re: Warnings?
Date: 
Message-ID: <sfwn2a7vngo.fsf@world.std.com>
"Jrm" <········@eval-apply.com> writes:

> I've worked with Lisps in which this is actually  the
> way to fool the compiler into thinking that you have
> `used' the variable (and thus supress unused variable
> warnings.)
 
Yeah, still to this day there are places I do 
 (defun foo (x)
    x ; ignored
    1)
because nearly every lisp knows this means not to warn about X and some
deviant lisps do not know about the IGNORE declaration. I also sometimes
do (dotimes (i 5) 
     (progn i) ;ignored - can't use just "i" because of tagbody in dotimes
     (print 'foo))
but notice this is -usually- with lexicals that one does this.  For an
example involving specials, you have to work harder, but I offer one at 
the end of this message.

> Rainer Joswig wrote in message ...
> >Given a function:
> >
> >(defun baz ()
> >  *foo*
> >  *bar*)
> >
> >Should the compiler warn that *foo* is not being used?

The important thing is that the warnings be possible to turn off.
Unreachable code or lost values is the inevitable result of automatic
programming (which includes macros).  To forbid it or even make
serious noise about it is to cripple any mechanical help in 
program-writing.  I used to write macros that resulted in

 (OR)
 (OR foo)
 (COND (T ...))
 (COND (T ...) (FOO ...))

and stuff like that and the compiler used to warn.  I ended up having
code that said:

 `(OR '$MAKE-COMPILER-HAPPY$ ,@x)

just to avoid the warning, but this in fact made the program slower
a lot of the time.  This is no way to make programmers work.  We define
degenerate cases because they are meaningful and while it's fine to
provide a mode where odd code gets flagged for easy debugging, one
doesn't want warnings about these things to get in the way of REAL 
warnings, such as the famous one from Symbolics Genera, which went
approximately like:

  For Macro FOO:
    The macro FOO was previously assumed to be a function.
    You will indubitably lose.

For example, the function BAZ in Rainer's mail could result from:

 (defmacro frob (&rest forms)
    `(let ((*frob-on* t))
       *default-frob-value*
       ,@forms))

 (defun baz () (frob *foo*))

The last thing you want to have to do is document the macro expansion 
so that the user is required to do:

 (defun baz () (declare (ignore *default-frob-value*)) (frob *foo*))

which would be even uglier!
From: Sunil Mishra
Subject: Re: Warnings?
Date: 
Message-ID: <efylnpr4t3u.fsf@cleon.cc.gatech.edu>
Kent M Pitman <······@world.std.com> writes:

> "Jrm" <········@eval-apply.com> writes:
> 
> > I've worked with Lisps in which this is actually  the
> > way to fool the compiler into thinking that you have
> > `used' the variable (and thus supress unused variable
> > warnings.)
>  
> Yeah, still to this day there are places I do 
>  (defun foo (x)
>     x ; ignored
>     1)

I have run into this more times than I can count, and each time I've wished
there were an ignorable declaration. Can't imagine it being *that* hard to
do, especially since the compiler knows when variables are not used.

Sunil
From: Kent M Pitman
Subject: Re: Warnings?
Date: 
Message-ID: <sfwg1fyr8vv.fsf@world.std.com>
Sunil Mishra <·······@cleon.cc.gatech.edu> writes:

> 
> Kent M Pitman <······@world.std.com> writes:
> 
> > "Jrm" <········@eval-apply.com> writes:
> > 
> > > I've worked with Lisps in which this is actually  the
> > > way to fool the compiler into thinking that you have
> > > `used' the variable (and thus supress unused variable
> > > warnings.)
> >  
> > Yeah, still to this day there are places I do 
> >  (defun foo (x)
> >     x ; ignored
> >     1)
> 
> I have run into this more times than I can count, and each time I've wished
> there were an ignorable declaration. Can't imagine it being *that* hard to
> do, especially since the compiler knows when variables are not used.

Well, Common Lisp does specify both IGNORE (must be ignored) and
IGNORABLE (may but does not have to be ignored) declarations, so
compilers these days are supposed to support it.  But the art of
writing robust code is a tricky one, so one can't always count on them
being there even though they're required.
From: Paul Dietz
Subject: Re: Warnings?
Date: 
Message-ID: <35B016DA.780C7D72@interaccess.com>
Rainer Joswig wrote:
> 
> Given a function:
> 
> (defun baz ()
>   *foo*
>   *bar*)
> 
> Should the compiler warn that *foo* is not being used?


I hope not.  I write macros that introduce temporaries
like this:

	(let ((temp ...))
	    temp
	    ...)

so that the compiler does not issue spurious warnings
if temp is not actually used in the rest of the let body.
This works under Franz's ACL.

	Paul
From: Erik Naggum
Subject: Re: Warnings?
Date: 
Message-ID: <3109736487728819@naggum.no>
* Paul Dietz
| I hope not.  I write macros that introduce temporaries like this:
| 
| 	(let ((temp ...))
| 	    temp
| 	    ...)
| 
| so that the compiler does not issue spurious warnings if temp is not
| actually used in the rest of the let body.  This works under Franz's ACL.

  ANSI Common Lisp provides an IGNORABLE declaration that should warn
  neither when the variable is used nor when not used.  (it is almost as
  annoying to have to declare unused variables in MULTIPLE-VALUE-BIND and
  such as it is to have a compiler whine that you lied to it about not
  using one of them.)  Franz Inc's Allegro Common Lisp [for Unix] has
  "always" had an EXCL::IGNORE-IF-UNUSED declaration that behaves exactly
  the same as IGNORABLE is specified to do, and ACL still uses it in the
  expansion of some macros that inquisitive users may run into, which is
  why they document it.  (4.3 User Guide, Appendix A, item 300.)

  while I tend to think the declaration syntax in CL is a bit on the
  verbose and cumbersome side, I still prefer them to hacks like the above.
  I'd be inclined to remove a line like that if I were to review such code.

  [pet peeve alert] ... and isn't it about time to demand ANSI CL semantics
  in the Common Lisps we use?

#:Erik
-- 
  http://www.naggum.no/spam.html is about my spam protection scheme and how
  to guarantee that you reach me.  in brief: if you reply to a news article
  of mine, be sure to include an In-Reply-To or References header with the
  message-ID of that message in it.  otherwise, you need to read that page.
From: Paul Dietz
Subject: Re: Warnings?
Date: 
Message-ID: <35B09F35.4AEB9D4D@interaccess.com>
Erik Naggum wrote:

>   ANSI Common Lisp provides an IGNORABLE declaration that should warn
>   neither when the variable is used nor when not used.

I didn't realize.  Thanks.

	Paul