From: "尾崎 成一" <mitararu@gmail.com>
To: 19828@debbugs.gnu.org
Subject: bug#19828: [PATCH] eval.c: couldn't make closures
Date: Tue, 10 Feb 2015 16:25:02 +0900 [thread overview]
Message-ID: <CABTrPHkhrQb9Qn2Fsmo02zp36LqCF55Jk_abW63M630srxh5qw@mail.gmail.com> (raw)
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. */
next reply other threads:[~2015-02-10 7:25 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-10 7:25 尾崎 成一 [this message]
2015-02-10 10:18 ` bug#19828: [PATCH] eval.c: couldn't make closures Shigekazu Ozaki
2015-02-10 11:17 ` Nicolas Richard
2015-02-10 12:06 ` Shigekazu Ozaki
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=CABTrPHkhrQb9Qn2Fsmo02zp36LqCF55Jk_abW63M630srxh5qw@mail.gmail.com \
--to=mitararu@gmail.com \
--cc=19828@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).