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.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19828 in the body.
You can then email your comments to 19828 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19828
; Package
emacs
.
(Tue, 10 Feb 2015 08:41:04 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
尾崎 成一 <mitararu <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 10 Feb 2015 08:41:04 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
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. */
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19828
; Package
emacs
.
(Tue, 10 Feb 2015 10:19:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 19828 <at> debbugs.gnu.org (full text, mbox):
Sorry everyone, if you attach this patch, Info-menu command won't work.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19828
; Package
emacs
.
(Tue, 10 Feb 2015 11:18:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 19828 <at> debbugs.gnu.org (full text, mbox):
Hello,
尾崎 成一 <mitararu <at> gmail.com> writes:
> The following code doesn't work because doesn't create any lexical
> environment correctly in Emacs 24.4.1.
I think this is not a bug. In order for emacs to create closures, you
need to enable lexical-binding (usually done via a file local variable
at the top of the file, e.g. using add-file-local-variable-prop-line).
See (info "(elisp) Closures").
HTH,
--
Nicolas Richard
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19828
; Package
emacs
.
(Tue, 10 Feb 2015 12:07:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 19828 <at> debbugs.gnu.org (full text, mbox):
>> The following code doesn't work because doesn't create any lexical
>> environment correctly in Emacs 24.4.1.
>
> I think this is not a bug. In order for emacs to create closures, you
> need to enable lexical-binding (usually done via a file local variable
> at the top of the file, e.g. using add-file-local-variable-prop-
> line).
>
> See (info "(elisp) Closures").
I see. I've misunderstood about the lexical bindings. Thank you. It's
very kind of you.
bug closed, send any further explanations to
19828 <at> debbugs.gnu.org and 尾崎 成一 <mitararu <at> gmail.com>
Request was from
Stefan Monnier <monnier <at> IRO.UMontreal.CA>
to
control <at> debbugs.gnu.org
.
(Tue, 10 Feb 2015 21:02:02 GMT)
Full text and
rfc822 format available.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 11 Mar 2015 11:24:04 GMT)
Full text and
rfc822 format available.
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.