I have the following code:
#+begin_src elisp
(setq lexical-binding t)
(let ((a 1)) ; binding (1)
(let ((f (lambda () (print a))))
(let ((a 2)) ; binding (2)
(funcall f)))) ; result: 2
#+end_src
Since I set lexical-binding
to t
, lexical bindings should be used instead of dynamic bindings. So I think the result of the above should be 1
. But the result is 2
. It's as if Emacs is still using dynamic bindings. Why? How can I make it use lexical bindings?