elisp - emacs: get lexically bound variable value by name -


this question has answer here:

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

Popular posts from this blog

c++ - Function signature as a function template parameter -

algorithm - What are some ways to combine a number of (potentially incompatible) sorted sub-sets of a total set into a (partial) ordering of the total set? -

How to call a javascript function after the page loads with a chrome extension? -