help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Can free variable refers to a lexical environment?


From: IWAKI Hidekazu
Subject: Can free variable refers to a lexical environment?
Date: Tue, 04 May 2010 15:42:00 -0000
User-agent: G2/1.0

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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]