GNU bug report logs -
#27674
26.0.50; cl-progv: strange scoping due to implementation
Previous Next
Reported by: Michael Heerdegen <michael_heerdegen <at> web.de>
Date: Wed, 12 Jul 2017 21:54:02 UTC
Severity: normal
Tags: notabug, wontfix
Found in version 26.0.50
Done: npostavs <at> users.sourceforge.net
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
tags 27674 notabug wontfix
close 27674
quit
Michael Heerdegen <michael_heerdegen <at> web.de> writes:
> npostavs <at> users.sourceforge.net writes:
>
>> > Why does the lambda still refer to the lexical binding?
>>
>> Maybe it would be more obvious if we wrote it like this:
>>
>> (let ((x 0))
>> (cl-progv (list (intern (read-string "Enter var: "))) (list 1)
>> (funcall (lambda () x))))
>>
>> Clearly the inner x must refer to the lexical let-binding, right? Even
>> if the user happens to enter `x' at the prompt this remains true.
>
> Not an argument per se, because with lexical binding mode off, you can
> surely do that.
Of course, if `x' is a dynamic variable (e.g., if you use (defvar x) or
you don't have lexical binding enabled) then the inner x refers to the
dynamic binding (again, regardless of what the user enters at the
prompt).
>> > Does a lexical binding always beat a dynamical one?
>>
>> Yes, lexical analysis is performed first and then the names are thrown
>> away, so you can't even tell when the "same" variable has been
>> dynamically bound as well.
>
> Ok, this is the part I was clearly missing, thanks. I'll have a look if
> the documentation tells something like this (it should be spelled out
> somewhere).
That explanation might be a little bit "infected" by my knowledge of how
the compiler implements lexical binding, the manual carefully talks only
in terms of the "evaluator":
Here is how lexical binding works. Each binding construct defines a
"lexical environment", specifying the variables that are bound within
the construct and their local values. When the Lisp evaluator wants
the current value of a variable, it looks first in the lexical environment.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
This bug report was last modified 8 years and 1 day ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.