bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#15416: Unused lexical argument warnings not optimized away in featur


From: Stefan Monnier
Subject: bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs
Date: Thu, 19 Sep 2013 09:55:22 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

> ; -*- 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





reply via email to

[Prev in Thread] Current Thread [Next in Thread]