GNU bug report logs -
#19828
[PATCH] eval.c: couldn't make closures
Previous Next
Reported by: 尾崎 成一 <mitararu <at> gmail.com>
Date: Tue, 10 Feb 2015 08:41:04 UTC
Severity: normal
Tags: notabug
Done: Stefan Monnier <monnier <at> IRO.UMontreal.CA>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Hi.
The following code doesn't work because doesn't create any lexical
environment correctly in Emacs 24.4.1.
(defvar my-ticker nil)
;; => my-ticker
(let ((x 0))
(setq my-ticker (lambda ()
(setq x (1+ x)))))
;; => (lambda nil
;; => (setq x
;; => (1+ x)))
(funcall my-ticker)
;; error--> Symbol's value as variable is void: x
After fixing that, it works well.
(defvar my-ticker)
;; => my-ticker
(let ((x 0))
(setq my-ticker (lambda ()
(setq x (1+ x)))))
;; => (closure
;; => ((x . 0))
;; => nil
;; => (setq x
;; => (1+ x)))
(funcall my-ticker)
;; => 1
(funcall my-ticker)
;; => 2
Regard,
Shigekazu
=== modified file 'src/eval.c'
--- src/eval.c 2014-09-16 04:04:56 +0000
+++ src/eval.c 2015-02-10 06:48:29 +0000
@@ -875,7 +875,7 @@
val = eval_sub (Fcar (Fcdr (elt)));
}
- if (!NILP (lexenv) && SYMBOLP (var)
+ if (SYMBOLP (var)
&& !XSYMBOL (var)->declared_special
&& NILP (Fmemq (var, Vinternal_interpreter_environment)))
/* Lexically bind VAR by adding it to the interpreter's binding
@@ -953,7 +953,7 @@
var = SYMBOLP (elt) ? elt : Fcar (elt);
tem = temps[argnum++];
- if (!NILP (lexenv) && SYMBOLP (var)
+ if (SYMBOLP (var)
&& !XSYMBOL (var)->declared_special
&& NILP (Fmemq (var, Vinternal_interpreter_environment)))
/* Lexically bind VAR by adding it to the lexenv alist. */
This bug report was last modified 10 years and 107 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.