[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: |
Wed, 12 Jul 2017 23:59:42 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) |
"Roland Winkler" <winkler@gnu.org> writes:
> > 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.
>
> Thanks, I thought about that:
>
> If var-list is the VARLIST for the let form, you should also use
> var-list to construct the alist that becomes the 2nd arg LEXICAL of
> eval. I believe, then it should not matter whether you have lexical
> binding on or off (untested!)
I don't think it's that simple: BINDS is unevaluated: it's a list of the
form ((SYMBOL EXPRESSION) ...). We would need to evaluate the bindings
twice (once to calculate the environment for `eval', and the second time
when evaluating the constructed form), which is unacceptable.
> So is this a bug in cl-progv? (I checked: this macro ignores the
> 2nd arg LEXICAL of eval.)
I think it's a bug, it's now filed as #27674.
Regards,
Michael.
- Re: let-bind a varlist only known at run time,
Michael Heerdegen <=