elisp - emacs: get lexically bound variable value by name -
this question has answer here:
- lexical eval in emacs24 3 answers
the following not work void variable error. should eval
replaced work?
;; -*- lexical-binding: t -*- (defun foo2 () (let ((b 'lkj)) (lambda () (eval 'b t)))) (funcall (foo2))
symbol-value
doesn't work either (as documented).
looking variable's value name fundamentally incompatible proper lexical scoping, because proper lexical scoping admits alpha-renaming, i.e. (consistently) renaming variable should not affect result.
of course, if must know, can hack things around in cases, doing things like:
(funcall `(closure ,(nth 1 <someclosure>) () <exp>))
which might evaluate <exp>
in same scope 1 <someclosure>
comes. won't work if <someclosure>
byte-compiled (or if made mistake).
Comments
Post a Comment