From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#51695: 29.0.50; lexical scope closure, interactive spec byte compiler warnings/usage issue Date: Wed, 10 Nov 2021 02:39:05 +0100 Message-ID: <87a6ic23ie.fsf@zoho.eu> References: <87k0hi2p3i.fsf@zoho.eu> <83r1bp5x6h.fsf@gnu.org> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="7396"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 51695@debbugs.gnu.org, monnier@iro.umontreal.ca To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Nov 10 02:40:52 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mkcbc-0001iE-DM for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 10 Nov 2021 02:40:52 +0100 Original-Received: from localhost ([::1]:41004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mkcbb-0002Xj-Cc for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 09 Nov 2021 20:40:51 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:32864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mkcao-0002XK-SV for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 20:40:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53084) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mkcan-0005JQ-Th for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 20:40:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mkcan-0000xc-RA for bug-gnu-emacs@gnu.org; Tue, 09 Nov 2021 20:40:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Emanuel Berg Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 10 Nov 2021 01:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 51695 X-GNU-PR-Package: emacs Original-Received: via spool by 51695-submit@debbugs.gnu.org id=B51695.16365083583631 (code B ref 51695); Wed, 10 Nov 2021 01:40:01 +0000 Original-Received: (at 51695) by debbugs.gnu.org; 10 Nov 2021 01:39:18 +0000 Original-Received: from localhost ([127.0.0.1]:36395 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkca6-0000wU-Ci for submit@debbugs.gnu.org; Tue, 09 Nov 2021 20:39:18 -0500 Original-Received: from sender11-pp-o91.zoho.eu ([185.20.211.249]:25264) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mkca4-0000wG-9w for 51695@debbugs.gnu.org; Tue, 09 Nov 2021 20:39:17 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1636508347; cv=none; d=zohomail.eu; s=zohoarc; b=SqLyB2UejKpA6EGAS8ZCi2xWq3u9dbJ00/BnxIK03Wo0EpgfMYFTkwurAB+Fqq5EoMYoUTL119T79CEB8Pn0pCETQQbdV/OocqI3bktEaT+t8l4STthi1I+E+Obq9/3fNzjSBeTARccV0Fm33vShrnzDX6wAv6JHDUt28rZFTYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.eu; s=zohoarc; t=1636508347; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=X42ebgsC6H1s0ol9u5mpJvUgyCncFPjLo+qIKJaYzF8=; b=UDK310JFrHFB1fMNXr01hKG41kXez715CPBuqiIfU5P37Sl1lcM2BV06EBtNwvABuJLwCbwHyeFKt3rYBBDWfHN49io5dSDnOCfyHb9L9MSqxa4BCcaM54DZ94yIQ25tAW30gwotwFCH4SlC/Z7Y01dN6VXhlzZzushvzWvrhIs= ARC-Authentication-Results: i=1; mx.zohomail.eu; dkim=pass header.i=zoho.eu; spf=pass smtp.mailfrom=moasenwood@zoho.eu; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1636508347; s=admin; d=zoho.eu; i=moasenwood@zoho.eu; h=From:To:Cc:Message-ID:Subject:References:Date:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=X42ebgsC6H1s0ol9u5mpJvUgyCncFPjLo+qIKJaYzF8=; b=Vpu1Fk98h+olfLwWgqq0lHbhGozA9a5XvnmTFujl+Vwqsd9NF6oivZKYjOADbTxz fPUmM72ps0vEw2IhxrHAl2r9x8kz2ZJCLD1fz7o/yT8zLfFHhMDfN2uJ9VVlxWfsznU EkErvzf77DTjoZlHWNoFBDXu95kqZY1Y5XPQ8OUQ= Original-Received: from ebih.zoho.eu (c-178e225c.021-67-7570702.bbcust.telenor.se [92.34.142.23]) by mx.zoho.eu with SMTPS id 1636508347256559.3490942888619; Wed, 10 Nov 2021 02:39:07 +0100 (CET) Mail-Copies-To: never In-Reply-To: <83r1bp5x6h.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 09 Nov 2021 14:29:58 +0200") X-ZohoMailClient: External X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:219498 Archived-At: Eli Zaretskii wrote: >> ;;; -*- lexical-binding: t -*- >> ;;; >> ;;; this file: >> ;;; http://user.it.uu.se/~embe8573/emacs-init/geh.el >> ;;; https://dataswamp.org/~incal/emacs-init/geh.el >>=20 >> (let ((data-item 1) >> (more-data 2) ) >> (defun echo-data (&optional data) >> (interactive (list (read-number "number: " (or data-item more-data= )))) >> (message "data: %s" (or data data-item)) )) >> ;; (echo-data 5) >> ;; (echo-data) >> ;; (call-interactively #'echo-data) >>=20 >> ;; Emacs bugs: >> ;; >> ;; 1. Byte compiler warnings (two cases) relating to the >> ;; interactive spec: >> ;; >> ;; geh.el:7:1: Warning: Unused lexical variable `more-data' >> ;; geh.el:10:54: Warning: reference to free variable =E2=80=98data-it= em=E2=80=99 >> ;; geh.el:10:64: Warning: reference to free variable =E2=80=98more-da= ta=E2=80=99 >> ;; >> ;; 2. When the compiled version is used interactively: >> ;; >> ;; Symbol's value as variable is void: data-item > > How can the interactive spec use lexically-bound variables > outside its scope, when the interactive spec runs not at > function definition time, but at function invocation time, > when those variables will be long gone? But it does work if you evaluate the code, isn't this discrepancy a problem? "Function definition time", is that the time of Elisp evaluation, byte compilation, or the loading of byte-compiled source BTW? I always felt static/lexical scope was completely natural, so for me personally it wasn't necessary, but the case I've heard several times is that one can make out what happens just by looking at the code. But here is a case when that's isn't enough since the behavior will differ based on other factors, as we have seen ... Also it would be preferable/intuitive if one could use closures so that the variable is available everywhere where it is spelled-out in the `let' form body ... Now we have seen that this isn't the case for `interactive' so then one has to wonder, where else isn't it available? PS. I looked in gmane.emacs.bugs but couldn't find this bug there ... maybe now it will appear? If not we can have the disucssion at gmane.emacs.help instead since that will involve more people, probably. --=20 underground experts united https://dataswamp.org/~incal