From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Kevin Ryde <user42@zip.com.au>
Cc: 6376@debbugs.gnu.org
Subject: bug#6376: 23.2; byte compile add-to-list report free variable
Date: Tue, 08 Jun 2010 21:29:20 -0400 [thread overview]
Message-ID: <jwvzkz56lrq.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87y6eqia4d.fsf@blah.blah> (Kevin Ryde's message of "Tue, 08 Jun 2010 11:30:42 +1000")
> I made a mistake with a variable name to add-to-list and wondered if the
> byte compiler might report
> (add-to-list 'nosuchvariable ...)
> as a free variable, similar to the report for
I use the code below for add-hook:
(byte-defop-compiler-1 remove-hook byte-compile-add-hook)
(defun byte-compile-add-hook (form)
(let ((sym (car-safe (cdr-safe form))))
(when (and (eq 'quote (car-safe sym))
(setq sym (car-safe (cdr sym)))
(symbolp sym))
;; Gross hack: We want to do the sanity checks just as we would for
;; a setq so we first do a setq and then pop the byte-code that was
;; just pushed by byte-compile-variable-ref.
(let ((byte-compile-output byte-compile-output)
(byte-compile-maxdepth byte-compile-maxdepth)
(byte-compile-depth byte-compile-depth))
(byte-compile-variable-ref 'byte-varset sym)))
(byte-compile-normal-call form)))
so I'm in favor of such a change, but it would need to be cleaned up such
that your byte-compile-check-assign is also used for
byte-compile-variable-ref (i.e. the code should be hoisted out of
byte-compile-variable-ref). Also, note that add-to-list is not only
a "varset" but also a "varref" (it reads the var before assigning to it).
Stefan
next prev parent reply other threads:[~2010-06-09 1:29 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-08 1:30 bug#6376: 23.2; byte compile add-to-list report free variable Kevin Ryde
2010-06-09 1:29 ` Stefan Monnier [this message]
2010-06-12 23:11 ` Kevin Ryde
2010-08-06 23:45 ` Kevin Ryde
2010-08-10 9:12 ` Stefan Monnier
2010-09-21 1:34 ` Kevin Ryde
2020-11-19 4:05 ` Stefan Kangas
2020-11-20 5:06 ` Stefan Kangas
2022-01-31 16:58 ` Lars Ingebrigtsen
2022-02-01 23:31 ` Michael Heerdegen
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=jwvzkz56lrq.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=6376@debbugs.gnu.org \
--cc=user42@zip.com.au \
/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).