From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Roland Winkler Newsgroups: gmane.emacs.bugs Subject: bug#27674: 26.0.50; cl-progv: strange scoping due to implementation Date: Thu, 13 Jul 2017 09:40:27 -0500 Message-ID: <871spkz9gk.fsf@gnu.org> 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> <87fue1dpo7.fsf@users.sourceforge.net> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1499957239 11735 195.159.176.226 (13 Jul 2017 14:47:19 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Thu, 13 Jul 2017 14:47:19 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) To: 27674@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 13 16:47:12 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 1dVfOM-000268-VE for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jul 2017 16:46:59 +0200 Original-Received: from localhost ([::1]:60465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfOS-00054g-2F for geb-bug-gnu-emacs@m.gmane.org; Thu, 13 Jul 2017 10:47:04 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfIf-0007r0-HT for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:41:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVfIc-00049S-A9 for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:41:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:34561) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVfIc-00049M-6t for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:41:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dVfIc-0003nc-0G for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:41:02 -0400 X-Loop: help-debbugs@gnu.org In-Reply-To: <87lgntfhky.fsf@drachen> Resent-From: Roland Winkler Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 13 Jul 2017 14:41:01 +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: notabug wontfix X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.149995685714587 (code B ref -1); Thu, 13 Jul 2017 14:41:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 13 Jul 2017 14:40:57 +0000 Original-Received: from localhost ([127.0.0.1]:37238 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVfIX-0003nD-In for submit@debbugs.gnu.org; Thu, 13 Jul 2017 10:40:57 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:39060) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dVfIW-0003n0-6l for submit@debbugs.gnu.org; Thu, 13 Jul 2017 10:40:56 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVfIQ-000429-1Q for submit@debbugs.gnu.org; Thu, 13 Jul 2017 10:40:51 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:44000) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dVfIP-00041m-UT for submit@debbugs.gnu.org; Thu, 13 Jul 2017 10:40:49 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVfIO-0007bF-In for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:40:49 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVfIL-0003wG-9M for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:40:48 -0400 Original-Received: from [195.159.176.226] (port=40372 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVfIL-0003v9-2J for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 10:40:45 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1dVfIC-0000M4-Vr for bug-gnu-emacs@gnu.org; Thu, 13 Jul 2017 16:40:36 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 38 Original-X-Complaints-To: usenet@blaine.gmane.org Cancel-Lock: sha1:t8HNnnWx+6NZNX0kbViZDWZ40BI= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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:134505 Archived-At: On Wed, Jul 12 2017, npostavs@users.sourceforge.net wrote: >>> > 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). I am not sure I can follow this thread: The docstring of cl-progv says Bind SYMBOLS to VALUES dynamically in BODY. But I am not sure whether this statement correctly reflects the actual code of cl-progv: cl-progv evaluates a let form at runtime, but it is not up to cl-progv to ensure dynamical binding. I believe it depends on whether lexical binding is on or off whether the code currently used by cl-progv uses dynamical binding or lexical binding. So it is my ignorant guess that a consistent behavior of cl-progv with lexical binding on or off requires that the bindings of SYMBOLS to VALUES is also passed to `eval' as a second arg. From the docstring of eval: LEXICAL can also be an actual lexical environment, in the form of an alist mapping symbols to their value.