GNU bug report logs -
#14772
24.3; defvar and lexical-binding in interpreted elisp code
Previous Next
Reported by: Jisang Yoo <jisang.yoo.ac+org <at> gmail.com>
Date: Tue, 2 Jul 2013 21:09:02 UTC
Severity: normal
Tags: wontfix
Found in version 24.3
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
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.
This bug report was last modified 5 years and 302 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.