From: Stefan Monnier <monnier@iro.umontreal.ca>
To: 12369@debbugs.gnu.org
Subject: bug#12369: 24.2.50; cl-loop: variable not left unused
Date: Thu, 06 Sep 2012 11:43:04 -0400 [thread overview]
Message-ID: <jwva9x3tb59.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87d31z1ets@ch.ristopher.com> (Christopher Schmidt's message of "Thu, 6 Sep 2012 14:06:05 +0100 (BST)")
> ;; -*- lexical-binding: t -*-
> (require 'cl-lib)
> (cl-loop for (rms . emacs) in nil)
> Byte compile this piece of code.
> Warning: Unused lexical variable `rms'
Yes, first bug: `emacs' is not listed as unused.
> Attempting to fix this warning by renaming rms to _rms results in
> another warning.
> Warning: variable `_rms' not left unused
Yup, second bug.
This is all due to the code generated by cl-loop which was optimized to
use `set' in the loop instead of `let'. This made sense for dynamically
scoped code where `let' is a bit slower, but for lexically-scoped code,
it's the exact opposite, so we should change the generated code from:
(identity
(catch '--cl-block-nil--
(let* ((--cl-var-- nil)
(emacs nil) (rms nil))
(while (consp --cl-var--)
(setq emacs (car --cl-var--) rms (pop emacs))
(setq --cl-var-- (cdr --cl-var--)))
nil)))
to
(identity
(catch '--cl-block-nil--
(let* ((--cl-var-- nil))
(while (consp --cl-var--)
(let* ((tmp (car --cl-var--))
(emacs (car tmp))
(rms (cdr tmp)))
(setq --cl-var-- (cdr --cl-var--))))
nil)))
-- Stefan
next prev parent reply other threads:[~2012-09-06 15:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-06 13:06 bug#12369: 24.2.50; cl-loop: variable not left unused Christopher Schmidt
2012-09-06 15:43 ` Stefan Monnier [this message]
2021-06-01 7:18 ` Lars Ingebrigtsen
2021-06-05 20:08 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwva9x3tb59.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=12369@debbugs.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 public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).