In an anonymous function such as
(lambda () x)
how can I replace the symbol x with its value in the current scope?
The only thing I can think of is
(eval `(lambda () ,x))
but I wonder if there's another way.
In an anonymous function such as
(lambda () x)
how can I replace the symbol x with its value in the current scope?
The only thing I can think of is
(eval `(lambda () ,x))
but I wonder if there's another way.
Stefan
On
The better solution is to add
;; -*- lexical-binding:t -*-
at the beginning of your file. Once you've done that, writing (lambda () x) is all it takes, since Emacs will then take care of replacing that x with the value from the scope surrounding that lambda (i.e. will create a proper closure).
Copyright © 2021 Jogjafile Inc.
Remove the
eval. Just`(lambda () ,x).That returns the list
(lambda () VAL-X), whereVAL-Xis the value of variablex. And a lambda list is interpreted by Emacs as a function.