From: Jisang Yoo <jisang.yoo.ac+org@gmail.com>
To: 14772@debbugs.gnu.org
Subject: bug#14772: 24.3; defvar and lexical-binding in interpreted elisp code
Date: Wed, 3 Jul 2013 05:52:02 +0900 [thread overview]
Message-ID: <CADtzDwbakcv0ujbw2+wRsULAmRk1mnUBWMnt+Gn6Qb6hZGj6ww@mail.gmail.com> (raw)
Short description:
Declaring a special variable affects lexical local variables of the
same name (in interpreted code) in a half measure way, thereby
deviating from both the newbies expectation and the common lisp
expectation.
Long description:
contents of alice.el:
;; -*- lexical-binding: t; -*-
;; two functions that are supposed to do the same thing
(defun alice-multiplier-1 (foo)
(lambda (n) (* n foo)))
(defun alice-multiplier-2 (num)
(let ((foo num))
(lambda (n) (* n foo))))
;; breaking bad
(defvar foo 1000)
;; time to see its effects
(print
(list
:R3 (mapcar (alice-multiplier-1 10) (list 1 2 3))
:R4 (mapcar (alice-multiplier-2 10) (list 1 2 3))))
Output from emacs -q --load alice.el:
(:R3 (10 20 30) :R4 (1000 2000 3000))
What I expected:
Either (:R3 (10 20 30) :R4 (10 20 30)) or (:R3 (1000 2000 3000) :R4
(1000 2000 3000))
One answer in
http://stackoverflow.com/questions/17400556/strange-interaction-between-lexical-binding-and-defvar-in-emacs-lisp
suggests that (:R3 (1000 2000 3000) :R4 (1000 2000 3000)) should be
the right output, which is the same as the CLIST output according to
my test.
next reply other threads:[~2013-07-02 20:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-02 20:52 Jisang Yoo [this message]
2013-07-03 9:30 ` bug#14772: 24.3; defvar and lexical-binding in interpreted elisp code Stefan Monnier
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=CADtzDwbakcv0ujbw2+wRsULAmRk1mnUBWMnt+Gn6Qb6hZGj6ww@mail.gmail.com \
--to=jisang.yoo.ac+org@gmail.com \
--cc=14772@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).