From: npostavs@users.sourceforge.net
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: 27674@debbugs.gnu.org
Subject: bug#27674: 26.0.50; cl-progv: strange scoping due to implementation
Date: Wed, 12 Jul 2017 22:41:12 -0400 [thread overview]
Message-ID: <87fue1dpo7.fsf@users.sourceforge.net> (raw)
In-Reply-To: <87h8yhdqvq.fsf@drachen> (Michael Heerdegen's message of "Thu, 13 Jul 2017 04:15:05 +0200")
tags 27674 notabug wontfix
close 27674
quit
Michael Heerdegen <michael_heerdegen@web.de> writes:
> npostavs@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.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
next prev parent reply other threads:[~2017-07-13 2:41 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-12 21:53 bug#27674: 26.0.50; cl-progv: strange scoping due to implementation Michael Heerdegen
2017-07-13 0:21 ` npostavs
2017-07-13 0:36 ` Michael Heerdegen
2017-07-13 0:50 ` npostavs
2017-07-13 1:11 ` Michael Heerdegen
2017-07-13 1:54 ` npostavs
2017-07-13 2:15 ` Michael Heerdegen
2017-07-13 2:41 ` npostavs [this message]
2017-07-13 14:40 ` Roland Winkler
2017-07-13 15:07 ` Noam Postavsky
2017-07-14 14:20 ` Michael Heerdegen
2017-07-15 20:46 ` Roland Winkler
2017-07-14 16:00 ` Michael Heerdegen
2017-07-19 13:55 ` Stefan Monnier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fue1dpo7.fsf@users.sourceforge.net \
--to=npostavs@users.sourceforge.net \
--cc=27674@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.