* bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs
@ 2013-09-19 2:51 Glenn Morris
2013-09-19 13:55 ` Stefan Monnier
0 siblings, 1 reply; 2+ messages in thread
From: Glenn Morris @ 2013-09-19 2:51 UTC (permalink / raw)
To: 15416
Package: emacs
Version: 24.3.50
Severity: minor
Byte-compiling this:
; -*- lexical-binding: t -*-
(if (featurep 'xemacs)
(defun foo (blah)
))
gives:
foo.el:2:1:Warning: Unused lexical argument `blah'
I thought code inside "(if (featurep 'xemacs)" was supposed to be
optimized away by the compiler?
^ permalink raw reply [flat|nested] 2+ messages in thread
* bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs
2013-09-19 2:51 bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs Glenn Morris
@ 2013-09-19 13:55 ` Stefan Monnier
0 siblings, 0 replies; 2+ messages in thread
From: Stefan Monnier @ 2013-09-19 13:55 UTC (permalink / raw)
To: Glenn Morris; +Cc: 15416
> ; -*- lexical-binding: t -*-
> (if (featurep 'xemacs)
> (defun foo (blah)
> ))
> gives:
> foo.el:2:1:Warning: Unused lexical argument `blah'
> I thought code inside "(if (featurep 'xemacs)" was supposed to be
> optimized away by the compiler?
It is optimized away later. The reason it is done later is ironically
to avoid such "unused arg" warnings in code like
(defun f (a b)
(if (featurep 'xemacs) (foo a b) (bar a)))
It is important for the warnings to relate as much as possible to the
actual source code rather than to its optimized form, otherwise you can
have warnings that are hard/impossible to fix. E.g.
(let ((x '(a b c d e g))) (bla x x x))
could complain "unused var x" because the optimizer replaced each use of
`x' with the corresponding constant.
Every failure to follow this principle leads to annoyances. Witness the
"unused lexical argument err" warnings for
(condition-case err <body> (scan-error nil) (error (message "%S" err)))
and similar problems with some macros.
Stefan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-09-19 13:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-19 2:51 bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs Glenn Morris
2013-09-19 13:55 ` Stefan Monnier
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.