all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@IRO.UMontreal.CA>
To: Glenn Morris <rgm@gnu.org>
Cc: 15416@debbugs.gnu.org
Subject: bug#15416: Unused lexical argument warnings not optimized away in featurep 'xemacs
Date: Thu, 19 Sep 2013 09:55:22 -0400	[thread overview]
Message-ID: <jwvmwn8yl8r.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <7szjr95xt6.fsf@fencepost.gnu.org> (Glenn Morris's message of "Wed, 18 Sep 2013 22:51:01 -0400")

> ; -*- 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	other threads:[~2013-09-19 13:55 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvmwn8yl8r.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=15416@debbugs.gnu.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.