From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: npostavs@users.sourceforge.net Newsgroups: gmane.emacs.bugs Subject: bug#27674: 26.0.50; cl-progv: strange scoping due to implementation Date: Wed, 12 Jul 2017 22:41:12 -0400 Message-ID: <87fue1dpo7.fsf@users.sourceforge.net> References: <87lgntfhky.fsf@drachen> <87r2xldw4s.fsf@users.sourceforge.net> <874luhf9zw.fsf@drachen> <87o9spdusk.fsf@users.sourceforge.net> <87zic9dtti.fsf@drachen> <87inixdru5.fsf@users.sourceforge.net> <87h8yhdqvq.fsf@drachen> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499913619 7641 195.159.176.226 (13 Jul 2017 02:40:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Jul 2017 02:40:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2.50 (gnu/linux) Cc: 27674@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 13 04:40:16 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVU32-0001SN-5j for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jul 2017 04:40:12 +0200 Original-Received: from localhost ([::1]:56918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVU34-0005oL-BK for geb-bug-gnu-emacs@m.gmane.org; Wed, 12 Jul 2017 22:40:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47053) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVU2w-0005mB-Aq for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2017 22:40:07 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVU2t-0005Ht-7v for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2017 22:40:06 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33354) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVU2t-0005Go-3d for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2017 22:40:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dVU2s-0006Cd-Ih for bug-gnu-emacs@gnu.org; Wed, 12 Jul 2017 22:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: npostavs@users.sourceforge.net Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Jul 2017 02:40:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 27674 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 27674-submit@debbugs.gnu.org id=B27674.149991358723815 (code B ref 27674); Thu, 13 Jul 2017 02:40:02 +0000 Original-Received: (at 27674) by debbugs.gnu.org; 13 Jul 2017 02:39:47 +0000 Original-Received: from localhost ([127.0.0.1]:36031 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVU2d-0006By-1T for submit@debbugs.gnu.org; Wed, 12 Jul 2017 22:39:47 -0400 Original-Received: from mail-it0-f67.google.com ([209.85.214.67]:33302) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVU2b-0006Bg-Ei; Wed, 12 Jul 2017 22:39:45 -0400 Original-Received: by mail-it0-f67.google.com with SMTP id 188so5085884itx.0; Wed, 12 Jul 2017 19:39:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=nefAFHwQopRxv6HbI2T5dDey7zJVB4wIimXtd/ou4M0=; b=IO7iInuFRGSoGX74hEBHqa3MMZ+LnIBQ7tAc954Ll721j77VkT2X3+XOER3c/O9mUh 0/chRUpNlZXPNv3O0AwNNC4BVulPID/XU0UWy8RlnuZujav8vQVwtj5DnsRx81Q/WKSn d/lOWDOTgD5V1QlI2XRb/BmaC+rCnyyRnJqBj4foeaas1jh4Walak5P2issNF9RNokzB sNFUgWFTk11R3FzfscoFH1MX4MxtpKz+ssm6V/sTtH6XXdvYodwmBrgpqppWfG0jaZb1 HC8UwRTjN6/LTvJx+GEBfycuTNh2gCBqIs981wvcaNdmhLoJChEuvkaUahfcTx8Q/kzy ZOoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=nefAFHwQopRxv6HbI2T5dDey7zJVB4wIimXtd/ou4M0=; b=aN/72fFcDaNaKWnQCdSO/UZeXNr5RU7pk83IMh6EXxci9icI6cfJSiWibl6N7okeCd qotQvBs8YbxVQqzwMr3W1y7yw6I70DoqbAULqqxKHgaKP4qajt6l3h0Z2C+ugstIpna0 GQAUrvhYCDWhUzxWQ+ZeKqUQjEPRFhG2wk0cUn2JOdw+5V/23fHu12Q4rMcxjn53gxiR nt6e1cVSSMAzffKRdmx8AjbjRe7VHQnDisyqxYAiBcxAFBhDQD2I78I06j8UcA1378Gz ECZXXATpO9t61JCd9tHZBrJ5DjzcDqVv4tmC+GasLOdHY/6ABnXVeA681ep6DgRRIsaR HiVA== X-Gm-Message-State: AIVw111/f+EiPLcl6GZ6QZi0spBUcMvUMwTuTVuBf42eIdMRT+KAVAi1 stuGYUqwZcHdiIuW X-Received: by 10.36.110.149 with SMTP id w143mr11203236itc.21.1499913579673; Wed, 12 Jul 2017 19:39:39 -0700 (PDT) Original-Received: from zony ([45.2.7.65]) by smtp.googlemail.com with ESMTPSA id g198sm252275itb.3.2017.07.12.19.39.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 12 Jul 2017 19:39:39 -0700 (PDT) In-Reply-To: <87h8yhdqvq.fsf@drachen> (Michael Heerdegen's message of "Thu, 13 Jul 2017 04:15:05 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:134492 Archived-At: tags 27674 notabug wontfix close 27674 quit Michael Heerdegen 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. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^