From: IWAKI Hidekazu <i.hidekazu@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Can free variable refers to a lexical environment?
Date: Tue, 9 Mar 2010 04:43:14 -0800 (PST) [thread overview]
Message-ID: <180666d9-2ecb-4d99-a419-739650a8fb3d@c37g2000prb.googlegroups.com> (raw)
Hello,
I need to make a table factory function in emacs with cl extension.
but I'm scheme user. I'm confusing emacs lisp behavior.
will you please tell me the emacs lisp's free variable issue.
my table factory function is following code:
(defun mk-table-instance ()
(let ((table nil)) ;; create a lexical value `table`
(defun __temp__ (msg &rest value)
;; some operation changes the lexical variable `table`
(case msg
((push) (push (car value) table))
(otherwise table)))
(function __temp__)))
;; return the `__temp__` procedure with the lexical variable `table`
;; i.e. return a closure.
(fset 'table-object (mk-table-instance))
;; 'table-object is an unique procedure object.
(table-object 'push 13)
;; my plan => operate an unique `table` variable which was created by
involving `mk-table-instance`
;; real => "Debugger entered--Lisp error: (void-variable
table)"!!!!!!!
I researched this code. I guess the lexical binded variable `table` in
`mk-table-instance` procedure refer to the global environment.
In scheme, the variable refer to the lexical environment.
How to refer to a lexical environment?
next reply other threads:[~2010-03-09 12:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-09 12:43 IWAKI Hidekazu [this message]
2010-03-09 18:21 ` Can free variable refers to a lexical environment? Barry Margolin
2010-03-10 4:47 ` IWAKI Hidekazu
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=180666d9-2ecb-4d99-a419-739650a8fb3d@c37g2000prb.googlegroups.com \
--to=i.hidekazu@gmail.com \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.