[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: let-bind a varlist only known at run time
From: |
Michael Heerdegen |
Subject: |
Re: let-bind a varlist only known at run time |
Date: |
Mon, 05 Jun 2017 04:49:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
"Roland Winkler" <winkler@gnu.org> writes:
> Normally the varlist for the special let form is hardcoded. Is it
> possible to specify the varlist only at runtime?
`cl-progv'?
> On the other hand, I expect that efficiency is not an issue for the
> body appearing in let. So if there is nothing else I could construct
> the complete let-form at runtime and pass it on to `eval'.
FWIW that's what `cl-progv' is doing, more or less. The body is pasted
into a lambda constructed before calling eval so that it can be
compiled. The resulting semantics can be a bit surprising, though; for
example
(let ((x 0))
(cl-progv (list 'x) (list 1)
(funcall (lambda () x))))
yields 0 with lexical-binding on, and
(cl-progv (list 'x) (list 1)
(funcall (lambda () x)))
yields 1.
Michael.