GNU bug report logs - #59057
Emacs 29. Byte compiler sometimes forgets about a defvar.

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Alan Mackenzie <acm@HIDDEN>; dated Sat, 5 Nov 2022 18:47:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 25 Nov 2022 10:36:17 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 25 05:36:17 2022
Received: from localhost ([127.0.0.1]:33646 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyW49-0004wU-9a
	for submit <at> debbugs.gnu.org; Fri, 25 Nov 2022 05:36:17 -0500
Received: from mx3.muc.de ([193.149.48.5]:34280)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1oyW47-0004wD-80
 for 59057 <at> debbugs.gnu.org; Fri, 25 Nov 2022 05:36:15 -0500
Received: (qmail 48675 invoked by uid 3782); 25 Nov 2022 11:36:07 +0100
Received: from acm.muc.de (p4fe1573d.dip0.t-ipconnect.de [79.225.87.61])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Fri, 25 Nov 2022 11:36:07 +0100
Received: (qmail 4710 invoked by uid 1000); 25 Nov 2022 10:36:06 -0000
Date: Fri, 25 Nov 2022 10:36:06 +0000
To: Stefan Kangas <stefankangas@HIDDEN>
Subject: Re: bug#59057: Emacs 29. Byte compiler sometimes forgets about a
 defvar.
Message-ID: <Y4Calk5lh6iGsLC5@ACM>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM> <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
 <jwvk03kks71.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=uPXmwU_efbjXb5AcZ7yd+pzzWbRiv6hgre5PTXXBPbQ@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <CADwFkm=uPXmwU_efbjXb5AcZ7yd+pzzWbRiv6hgre5PTXXBPbQ@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org, Stefan Monnier <monnier@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Thu, Nov 24, 2022 at 22:12:07 +0100, Stefan Kangas wrote:
> > I don't see any concrete benefit.  It's only a problem of documentation
> > and/or teaching programmers.  If we could go back to 1984 maybe it would
> > be worth it to make a different decision, but the cost of the change
> > doesn't seem worth the very minor (and hypothetical) benefit.

> So should this bug report be closed?

The action of defvar can't really be changed any more, but the
documentation, which is rather confusing, could be improved.  I would
suggest leaving the bug open until this has been done.  Unfortunately, I
won't have much time to look at this in the next few days.

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 24 Nov 2022 21:12:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 16:12:26 2022
Received: from localhost ([127.0.0.1]:60421 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyJWE-0007rI-EA
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 16:12:26 -0500
Received: from mail-oi1-f174.google.com ([209.85.167.174]:44730)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1oyJWC-0007r2-OI
 for 59057 <at> debbugs.gnu.org; Thu, 24 Nov 2022 16:12:25 -0500
Received: by mail-oi1-f174.google.com with SMTP id e205so2597240oif.11
 for <59057 <at> debbugs.gnu.org>; Thu, 24 Nov 2022 13:12:24 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:from:to:cc:subject:date:message-id:reply-to;
 bh=w0kzUmQsrxNt/SAI1dlAG+CyqiYhfeS+V7Lr/06Wqyk=;
 b=ODMpm47686DRqVri62mEa3gCciSed1DlxiyVtN0J7ru7J+r1VdQlBgTeb6T8DQrE9e
 f0CuACfFvFu7I88PODrZEoPTGQVRjFUMel9j8EEYNEBZIiSSZ7knjRj9LBjWmfoS4X/i
 KdGwFeT4aGwtGyLs5W8pFGs5fO2Yb/joyIf69nBSr+W602fVIJ3lnGMyOQ9bCkRPpigV
 nlkwpDvVYEws3qx+2fU9m+Qaa+qRwDT0Owrn/XFixx8HtnKRcMo7Y32clcAC0xeSkLF0
 b8jjfpN5Ct9SEMV57OwMEShwniJta9BHui/PNBQVc33P2SB9lfcCvHc4u0nU1F83sr6d
 AeOQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:from:in-reply-to:references
 :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=w0kzUmQsrxNt/SAI1dlAG+CyqiYhfeS+V7Lr/06Wqyk=;
 b=2XnmWPSw8CojzRzkdkBsEd/IIYWfOL7q4dXkVpdw0BKDoNfbwsOORWHhTPWTzXADUk
 jkrd60SFDlQDiyGPTTnxKc2QaKHxVhRUJDwXu5zmmCpkpvlUkJCtQ+IEuRqpbpptGqZ6
 xCp8ETg5MJZbN0anWVN/GTDWBdeKyBMDOnqNOs8Y7r8ZZD7oL3/qWuQtZm+unvMswVR4
 SpsOLCxuuUMfVxvIPRihWEF8IJBYybLYadtJwHzRddrIdUiwjmSiOgGLkKZdGq17Jx4t
 aOe/b1Ly1QqMMKVZJ/ETbZD0uA3/ar5qZwxGexs09cbZuO3YTsU2lN1sNLNMkBlvjrgq
 ilxw==
X-Gm-Message-State: ANoB5pmleqi3bLsDiOVAoHhTIjMJF27he8IlFuLvUewDS9CgAFhC6kNB
 t56sv/PpgOUlx/zzDu3SBv/Ag4aaJEZqdkPhGyU=
X-Google-Smtp-Source: AA0mqf4UZNKl2FhZkwhkeBxCjX+rHpNG9P7HA0qVnqR2/w6EL0thl9+CQz+VOTCZiVCieZ6CNQ4Dmuj6ho3pizsvW+s=
X-Received: by 2002:a05:6808:2229:b0:35b:2b17:af81 with SMTP id
 bd41-20020a056808222900b0035b2b17af81mr7681213oib.199.1669324338967; Thu, 24
 Nov 2022 13:12:18 -0800 (PST)
MIME-Version: 1.0
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM> <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
 <jwvk03kks71.fsf-monnier+emacs@HIDDEN>
In-Reply-To: <jwvk03kks71.fsf-monnier+emacs@HIDDEN>
From: Stefan Kangas <stefankangas@HIDDEN>
Date: Thu, 24 Nov 2022 22:12:07 +0100
Message-ID: <CADwFkm=uPXmwU_efbjXb5AcZ7yd+pzzWbRiv6hgre5PTXXBPbQ@HIDDEN>
Subject: Re: bug#59057: Emacs 29. Byte compiler sometimes forgets about a
 defvar.
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: Alan Mackenzie <acm@HIDDEN>, 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

> I don't see any concrete benefit.  It's only a problem of documentation
> and/or teaching programmers.  If we could go back to 1984 maybe it would
> be worth it to make a different decision, but the cost of the change
> doesn't seem worth the very minor (and hypothetical) benefit.

So should this bug report be closed?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 24 Nov 2022 20:36:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 15:36:28 2022
Received: from localhost ([127.0.0.1]:60393 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyIxQ-00070F-1p
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 15:36:28 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:49523)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1oyIxN-000701-Vz
 for 59057 <at> debbugs.gnu.org; Thu, 24 Nov 2022 15:36:26 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 04B331000DF;
 Thu, 24 Nov 2022 15:36:20 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 08CC610002A;
 Thu, 24 Nov 2022 15:36:18 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1669322178;
 bh=xwDILxwMN+q3lQACcYLHSoHrz8jq/RzIWSBnKQQ0kyw=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=KrPexcm24xrJOCo6MoZlQZVbypQkHn7veRLR2aR1JC0LRioZrwepjQ901p0nnXGnV
 Yduu2WeoWNbZxDDFs/uFdZpuQlngw1Fozz+OZxiD1m45w3hP82jtxWMAKa8cFgjGiB
 6WOFHjhsVX6KFGbI72mIULLQeMjbZVue/NoUvfAs6n0MrQ3ugratw6j/3/qjm/00Fb
 ywi3zECbp4qnunwHaWiexDI7Yo6TaQwCy72PLA0d+jUvOLzPONzPSVunNMP7eAsSLe
 WyC+Vm7NrC4UzNneCuwUWcII4P+usr9tuxzzohMLbY13CMJSLPTVzAwZuClNs71e4e
 gYEPc469X9vNA==
Received: from alfajor (unknown [45.44.229.252])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B6D4C120472;
 Thu, 24 Nov 2022 15:36:17 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
Subject: Re: bug#59057: Emacs 29. Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
 (Stefan Kangas's message of "Thu, 24 Nov 2022 11:29:32 -0800")
Message-ID: <jwvk03kks71.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM> <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
Date: Thu, 24 Nov 2022 15:36:17 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results: =?UTF-8?Q?0=0A=09?=ALL_TRUSTED -1 Passed
 through trusted hosts only via =?UTF-8?Q?SMTP=0A=09?=AWL -0.014 Adjusted
 score from AWL reputation of From: =?UTF-8?Q?address=0A=09?=BAYES_00 -1.9
 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily =?UTF-8?Q?valid=0A=09?=DKIM_VALID -0.1 Message has at least
 one valid DKIM or DK =?UTF-8?Q?signature=0A=09?=DKIM_VALID_AU -0.1 Message
 has a valid DKIM or DK signature from author's domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: Alan Mackenzie <acm@HIDDEN>, 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> I guess defvar will have to stay as it is.  But would it make sense to
> add a new `declare-variable' function, and then document the form
>
>     (defvar <foo>)
>
> to be considered deprecated?

I don't see any concrete benefit.  It's only a problem of documentation
and/or teaching programmers.  If we could go back to 1984 maybe it would
be worth it to make a different decision, but the cost of the change
doesn't seem worth the very minor (and hypothetical) benefit.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 24 Nov 2022 19:33:13 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 14:33:12 2022
Received: from localhost ([127.0.0.1]:60254 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyHyC-0000qs-Jx
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 14:33:12 -0500
Received: from eggs.gnu.org ([209.51.188.92]:35054)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1oyHyA-0000qe-T6
 for 59057 <at> debbugs.gnu.org; Thu, 24 Nov 2022 14:33:11 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oyHy4-0004Pe-AO; Thu, 24 Nov 2022 14:33:04 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=VMxoLzXZPyX/G5o0+5jjZ6MTZWPKPCc4sRmIs034KSc=; b=QHD3dhjGyv9c
 LkTVY9YJyTQMjgRToq4VWUzOWvYGAlLbWh3+jQwBp3MWloe+FUpGGQbyiuRzoBYRwyib26FbMbjlg
 NnX5XQYftG4WzTeXgB8nIQVXP9WgCXFLb4mTwTbKpLZdS6lc4cdVy/bxkeQgwomgjLzbwJab1ThX+
 mQIoz4UGDwbgNHHkhtyFaXJ430Y8UCBUFZ5f3ehMizYZtfCdl6Vc1Kbg9seTy6S9iLgxmTmWrdF4s
 9q6Kls4vtOXQPSNmfwkW9PwvAdgIgTJcl+4W2yyLYxDDh0D+xQog5dGCwj+q68x5OR+Aqbta/0yeG
 CYqIn8YRERwlr6FmseNRqw==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1oyHy3-0003mD-HJ; Thu, 24 Nov 2022 14:33:03 -0500
Date: Thu, 24 Nov 2022 21:33:24 +0200
Message-Id: <83wn7kuozf.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
 (message from Stefan Kangas on Thu, 24 Nov 2022 11:29:32 -0800)
Subject: Re: bug#59057: Emacs 29. Byte compiler sometimes forgets about a
 defvar.
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM> <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
 <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: acm@HIDDEN, monnier@HIDDEN, 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> Cc: Alan Mackenzie <acm@HIDDEN>, 59057 <at> debbugs.gnu.org
> From: Stefan Kangas <stefankangas@HIDDEN>
> Date: Thu, 24 Nov 2022 11:29:32 -0800
> 
> Stefan Monnier <monnier@HIDDEN> writes:
> 
> >> The basic problem is that defvar is a dog's breakfast of a function.  In
> >> fact, it's two distinct functions sharing a name.  These two functions
> >> have little else to do with eachother.
> >
> > Yup.
> >
> >> And defvar appears to be the only function in Emacs where supplying nil
> >> as an &optional argument has an effect different from omitting it.  This
> >> is bad for anybody trying to learn Emacs Lisp.
> >
> > Not the only one, sadly (`declare-function` comes to mind :-)), but yes,
> > it's unusual.
> 
> I guess defvar will have to stay as it is.  But would it make sense to
> add a new `declare-variable' function, and then document the form
> 
>     (defvar <foo>)
> 
> to be considered deprecated?

It makes no sense to me to deprecate (defvar FOO).  There are only
disadvantages down that path (massive annoyance or breakage of third-party
code, if nothing else).  Please don't.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 24 Nov 2022 19:29:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Nov 24 14:29:40 2022
Received: from localhost ([127.0.0.1]:60239 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oyHum-0006tP-E6
	for submit <at> debbugs.gnu.org; Thu, 24 Nov 2022 14:29:40 -0500
Received: from mail-oa1-f45.google.com ([209.85.160.45]:44726)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <stefankangas@HIDDEN>) id 1oyHuk-0006tB-Ev
 for 59057 <at> debbugs.gnu.org; Thu, 24 Nov 2022 14:29:38 -0500
Received: by mail-oa1-f45.google.com with SMTP id
 586e51a60fabf-142306beb9aso2876892fac.11
 for <59057 <at> debbugs.gnu.org>; Thu, 24 Nov 2022 11:29:38 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=B4OKCsD9qjMZ16emFsCCIqKLJu87+sOp3vTGGBptYbc=;
 b=FAfPyvLBKyRUQif1nXlTCktH4QT07UYL+VOgw8/larn8BlcmLWcWrKyG6qyMQCrxJw
 Zb9OSfHh6brRP+y6mV9QEk6SEksKrd8kAQ5mP9qIMvF5UhWs9xg/K6WMqSa/KvmN1O8l
 Xlv7T1DBkwmon15Pg4szsqHf6ud2JzVIEuRUip/72cA6+AiaByaE9bVJ/nLaDmhKUBp6
 kQJzLxd83QOlYiAlXcKxtE0IqP0SzsTLXAPw8UvUpN/PmLUrxTKB7dz9PiKSLmchYCr1
 SttZlswBrb9bZwW2zkkoFE6tE3X0tIk8vjdQeAW1VJG+2/PICe5Eotk1aLwPvwebO1Mv
 Nk3w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=cc:to:subject:message-id:date:mime-version:references:in-reply-to
 :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to;
 bh=B4OKCsD9qjMZ16emFsCCIqKLJu87+sOp3vTGGBptYbc=;
 b=M7cMmz3aFnB2w1583Mo+4J3yf2peg6Ha6wNL5uxYuL0dY2N1BQGChCixGhdmle95Sm
 fqTn9xDj5G9WdauICSyBf+euwUHMXdxqwcRFGGIXZzv3SVPhhP1KJMNAD1dCVOY279E6
 x4D7UrOogJOhxgPKqRmFFnYrS6pckQRqGVdHBWWi4kXV9IpSL9rsPUmhsM4ttfQO6tWl
 Vy0L5cfAlidBOw1eV4TDz5V+Q2pBI7Jj7HWRKYwnzZ23v/eR0EcwX6AVG9idWTrmrbAV
 wGISVvIpWVhkvJT7pAfNppkL5pWYRHApUHDXpJebM32QFSp/z5W7TsDgbmwOdlVQlYRH
 ufXQ==
X-Gm-Message-State: ANoB5pnjnglyl4VjBPpkpNiowrz8AxeoAxgV6pyNlDMNPdcT0gWfV5kd
 YAU7CvUZ3Qy3cFHR+qVT7sT3pmBtBau69jDmzNE=
X-Google-Smtp-Source: AA0mqf6Sbju3v+P0gjjnLOL7MyYbGHh1fwriOEJrjlkBtZGGezUbJvYiVh7qpihVSqmeUwcIZTePKAXy4VJcJxSPKCw=
X-Received: by 2002:a05:6870:cc89:b0:12b:fbe7:b793 with SMTP id
 ot9-20020a056870cc8900b0012bfbe7b793mr21388375oab.92.1669318172843; Thu, 24
 Nov 2022 11:29:32 -0800 (PST)
Received: from 753933720722 named unknown by gmailapi.google.com with
 HTTPREST; Thu, 24 Nov 2022 11:29:32 -0800
From: Stefan Kangas <stefankangas@HIDDEN>
In-Reply-To: <jwvsfisqakd.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
 of "Wed, 09 Nov 2022 12:54:57 -0500")
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM> <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
X-Hashcash: 1:20:221124:59057 <at> debbugs.gnu.org::zdVhoLhhxPkM5oj7:CxAX
MIME-Version: 1.0
Date: Thu, 24 Nov 2022 11:29:32 -0800
Message-ID: <CADwFkm=z8STfz5abAUc-Y72z-cH_XwDxvKwi9qGWDnhTcxxOEw@HIDDEN>
Subject: Re: bug#59057: Emacs 29. Byte compiler sometimes forgets about a
 defvar.
To: Stefan Monnier <monnier@HIDDEN>
Content-Type: text/plain; charset="UTF-8"
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: Alan Mackenzie <acm@HIDDEN>, 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Stefan Monnier <monnier@HIDDEN> writes:

>> The basic problem is that defvar is a dog's breakfast of a function.  In
>> fact, it's two distinct functions sharing a name.  These two functions
>> have little else to do with eachother.
>
> Yup.
>
>> And defvar appears to be the only function in Emacs where supplying nil
>> as an &optional argument has an effect different from omitting it.  This
>> is bad for anybody trying to learn Emacs Lisp.
>
> Not the only one, sadly (`declare-function` comes to mind :-)), but yes,
> it's unusual.

I guess defvar will have to stay as it is.  But would it make sense to
add a new `declare-variable' function, and then document the form

    (defvar <foo>)

to be considered deprecated?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 9 Nov 2022 17:55:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 09 12:55:15 2022
Received: from localhost ([127.0.0.1]:40836 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1ospIA-0003pv-UQ
	for submit <at> debbugs.gnu.org; Wed, 09 Nov 2022 12:55:15 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:4418)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1ospI9-0003pg-BX
 for 59057 <at> debbugs.gnu.org; Wed, 09 Nov 2022 12:55:14 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 19CA680796;
 Wed,  9 Nov 2022 12:55:06 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 5D3F880762;
 Wed,  9 Nov 2022 12:55:04 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1668016504;
 bh=s44yGKvbiXDGsbe294P0EWtC49US4PKrWs1YzABJpho=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=DP3gBkdcgZw+hLeXDaD7MPqO2mnPijK4yVZcrzQYcyKnUW5OOJAy5SnDx9ClvftYe
 VmqnhNDnS1Xohs4ynssMN+paChcDoIE3d1d4FwVmneKAUvMIkJrnFAgogqoO007Ds5
 3EPpGiM+AcHbu5dp3uRJYr+ENcNSS/O2JdEq+6qNRGtZ8YYTmUJTfbwyR9Nvacmekx
 wUDPvieVQrf6iUWpVLIoVAFhKXBl3GghKlnFThnfCpYMAa9t+r4ocMiaf8jaccjxNE
 pKGO3Sclj22MxYYV/RE7YaeRbnKfAoumfscKXwn+1dYujJbFW5DbPwF7/8+rYsBiEr
 sMgCq7Tool8UQ==
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id EEE06120851;
 Wed,  9 Nov 2022 12:55:03 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <Y2ut6a7AONZYR7Sy@ACM> (Alan Mackenzie's message of "Wed, 9 Nov
 2022 13:40:57 +0000")
Message-ID: <jwvsfisqakd.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
 <Y2ut6a7AONZYR7Sy@ACM>
Date: Wed, 09 Nov 2022 12:54:57 -0500
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.045 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> The basic problem is that defvar is a dog's breakfast of a function.  In
> fact, it's two distinct functions sharing a name.  These two functions
> have little else to do with eachother.

Yup.

> And defvar appears to be the only function in Emacs where supplying nil
> as an &optional argument has an effect different from omitting it.  This
> is bad for anybody trying to learn Emacs Lisp.

Not the only one, sadly (`declare-function` comes to mind :-)), but yes,
it's unusual.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 9 Nov 2022 13:41:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 09 08:41:10 2022
Received: from localhost ([127.0.0.1]:39315 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1oslKI-0003GS-JU
	for submit <at> debbugs.gnu.org; Wed, 09 Nov 2022 08:41:10 -0500
Received: from mx3.muc.de ([193.149.48.5]:54324)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1oslKE-0003Fg-1K
 for 59057 <at> debbugs.gnu.org; Wed, 09 Nov 2022 08:41:09 -0500
Received: (qmail 77014 invoked by uid 3782); 9 Nov 2022 14:40:59 +0100
Received: from acm.muc.de (p4fe1582d.dip0.t-ipconnect.de [79.225.88.45])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Wed, 09 Nov 2022 14:40:59 +0100
Received: (qmail 6919 invoked by uid 1000); 9 Nov 2022 13:40:57 -0000
Date: Wed, 9 Nov 2022 13:40:57 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
Message-ID: <Y2ut6a7AONZYR7Sy@ACM>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Mon, Nov 07, 2022 at 16:31:32 -0500, Stefan Monnier wrote:
> >> (defvar VAR) does not "create a variable".
> > According to both its doc string and the Elisp manual it does.

> BTW, what I'm describing is how things have worked in `lexical-binding`
> since Emacs-24, basically.  A few corner cases didn't quite obey it
> (and I'm sure there are still a few remaining ones), but by and large
> this is how it has worked for the last 10 years.

OK, I see that now, having checked git logs and git blame.  There was a
bug report in 2018 about the documentation, which Noam Postavsky fixed.

The basic problem is that defvar is a dog's breakfast of a function.  In
fact, it's two distinct functions sharing a name.  These two functions
have little else to do with eachother.

And defvar appears to be the only function in Emacs where supplying nil
as an &optional argument has an effect different from omitting it.  This
is bad for anybody trying to learn Emacs Lisp.

Because defvar isn't a single function, it's impossible to document it
coherently without explicitly saying it's two functions.  I doubt the
powers that be would countenance such explicitness.  So the
documentation will continue to be confusing, and people like me will
continue to lose time sorting out what this hybrid function does.

I will alter the code in CC Mode which gave rise to this bug report.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 8 Nov 2022 14:12:53 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 08 09:12:52 2022
Received: from localhost ([127.0.0.1]:36709 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1osPLQ-0001YI-Jf
	for submit <at> debbugs.gnu.org; Tue, 08 Nov 2022 09:12:52 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:17625)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1osPLK-0001Xz-Rb
 for 59057 <at> debbugs.gnu.org; Tue, 08 Nov 2022 09:12:50 -0500
Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id DD8B8442180;
 Tue,  8 Nov 2022 09:12:40 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 9E85144217B;
 Tue,  8 Nov 2022 09:12:39 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1667916759;
 bh=pPY/AMw6tYgtQePKZSm9tLHp9akK5tVz5DaiTluf1gw=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=BElF/w51kN8d2MSRr4hVXeWuDdtFYCsDdzwvg8XdIOu+OG9VjS+9MYvChkfmgF6Aa
 oZrsrZVBkwI/JREaomfgqU+HB8CQlIDiMfbZOdLNMoow9f3bHj7Z229MNYNw6kBboL
 NHFY0l6ZEYYHQIVIJTpnNY4oskW8WPGjYosfpqaWwC5rjma4AOvA5ovcW/U/kH3TM2
 05Oc4hplQbtd62QnkgG7sQv+OPjHiTBP2mHbGfe13aKVyVQgwVUgcs4hCm5+77Y7Dq
 fXYdO9r8uMPYzY+ksZ77Ge0meDHV5203epliEVQ+hwb1vBKnVs9GYy7Futk8iUN05T
 8WufzMpW/d2gQ==
Received: from pastel (unknown [104.247.241.157])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6640312008F;
 Tue,  8 Nov 2022 09:12:39 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <Y2o2/UJeAShsSP+8@ACM> (Alan Mackenzie's message of "Tue, 8 Nov
 2022 11:01:17 +0000")
Message-ID: <jwvpmdxv92h.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwvbkpiv4qh.fsf-monnier+emacs@HIDDEN>
 <Y2o2/UJeAShsSP+8@ACM>
Date: Tue, 08 Nov 2022 09:12:38 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.002 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> The recently introduced special handling of defvar without a value is
> not welcome.

`defvar` without a value has been treated specially (more specifically
as a pure compiler-directive with no run-time effect) since at least
Emacs-19.34, so I'm not sure "recently" can be applied here.

> Why should anybody want a dynamic variable later to be
> a lexically scoped variable?.  

E.g. for historical reasons `calendar.el` needs to bind dynamically the
variable `date` around some calls to `eval` and to `run-hooks` because
the code evaluated therein has been defined and documented for may years
before to have access to important info via those dynbound vars.

Yet, we don't want `date` to be globally declared as being
always dynbound just because of that package's mishap, do we?

Similar situations affect other innocent-looking vars in other packages.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 8 Nov 2022 11:01:27 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 08 06:01:27 2022
Received: from localhost ([127.0.0.1]:36418 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1osMMB-0004Wb-8v
	for submit <at> debbugs.gnu.org; Tue, 08 Nov 2022 06:01:27 -0500
Received: from mx3.muc.de ([193.149.48.5]:64375)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1osMM9-0004WN-6N
 for 59057 <at> debbugs.gnu.org; Tue, 08 Nov 2022 06:01:26 -0500
Received: (qmail 93465 invoked by uid 3782); 8 Nov 2022 12:01:18 +0100
Received: from acm.muc.de (p4fe1541b.dip0.t-ipconnect.de [79.225.84.27])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Tue, 08 Nov 2022 12:01:17 +0100
Received: (qmail 6008 invoked by uid 1000); 8 Nov 2022 11:01:17 -0000
Date: Tue, 8 Nov 2022 11:01:17 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
Message-ID: <Y2o2/UJeAShsSP+8@ACM>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM> <jwvbkpiv4qh.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwvbkpiv4qh.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Mon, Nov 07, 2022 at 16:29:15 -0500, Stefan Monnier wrote:
> >> (defvar VAR) does not "create a variable".

> > According to both its doc string and the Elisp manual it does.

> Where?  I'm talking specifically about (defvar VAR) not about
> `defvar` in general.

The entry in the Elisp manual starts off:

     This special form defines SYMBOL as a variable.  Note that SYMBOL
     is not evaluated; the symbol to be defined should appear explicitly
     in the `defvar' form.  The variable is marked as "special", meaning
     that it should always be dynamically bound (see Variable
     Scoping).

"This special form defines SYMBOL as a variable.".  There are no ifs,
buts, whens, or whenevers in that sentence.  This is, at best, somewhat
confusing.

Note also: "... that it should ALWAYS be dynamically bound ...".

I suppose you're now going to say that "defining" a variable is
different from "creating" it.  And that you're going to say "always"
doesn't mean always.

From defvar's doc string:

    The `defvar' form also declares the variable as "special",
    so that it is ALWAYS dynamically bound even if `lexical-binding' is t.

Here, again, you're going to say that "always" only means "sometimes", I
think.

> >> It just "locally" declares that this identifier should use dynamic
> >> scoping when binding a variable.
> > Why "locally"?  There's just one obarray involved, which is global.

> No, we want to allow `defvar` to have a lexically-local effect.

Why?  What's the use case?  This, again, is contradictory: a defvar with
a value has global effect, but without a value has only lexical scope.
This doesn't make sense.  Why should dynamically bound variables have
lexical scope?  Could it be the enthusiasm for lexical binding has burst
beyond its natural limits?

> >> But the better way to write the above code is:

> >>     (defmacro acm-defvar (var)
> >>       `(progn
> >>          (defvar ,var)
> >>          (eval-when-compile
> >>            (when (version-check)
> >>              (setq ,var emacs-major-version)))))

> > There are workarounds, yes.  But surely it would be better to fix the
> > bug.

> It's not a workaround.  It's how the programmers say whether they want
> the (defvar ,var) declaration to affect all the rest of the code or only
> the code within the `when`.

I think programmers just want defvar to behave sensibly and
consistently, and in accordance with the documentation.  The recently
introduced special handling of defvar without a value is not welcome.
Why should anybody want a dynamic variable later to be a lexically
scoped variable?.  

> Why put the (defvar ,var) within the `when` if not to limit
> its scope?

To limit when it will create the variable, according to the value of the
enclosing `if' form.  Just like if you do a (setq my-global some-value),
that has effect outside of the lexical scope.

In my test program, l-s-p is created with a dynamic binding, but later
on it got a confusing warning about it being unused as a lexically bound
variable.  Nobody wants this, surely?

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 21:31:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 07 16:31:42 2022
Received: from localhost ([127.0.0.1]:35585 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1os9iY-0004ji-Kx
	for submit <at> debbugs.gnu.org; Mon, 07 Nov 2022 16:31:42 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:7790)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1os9iX-0004jV-Nf
 for 59057 <at> debbugs.gnu.org; Mon, 07 Nov 2022 16:31:42 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 70807100189;
 Mon,  7 Nov 2022 16:31:36 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 146F51000F4;
 Mon,  7 Nov 2022 16:31:35 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1667856695;
 bh=BDPHDuvuMFVJw4l0bxLDtwaSWgM93A7vXurvqh1cxVQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=NsipFuA6BGh/fbQj2gtU8lAuPeehstev3zoLs/JiRvR+wQ+hrYoreacknL+ZMivlk
 Z7pWq5CMDR5cTQSgF2CwSYnOkFcSwVy2MutBGjcToCDJv9UbFaRFYy8033S546f8IV
 Ee+3E5ABQq2xexx2pBYQmVutb29XhYAFk/ke1BWTOg8RC2TQkRgSvM8HG0Z/uCOeAt
 YbBdfM+UnRdQWyOW824BMpv3GqUJ22Ttnx0OGIQAP97KmKd5Y78gDUVQUyq/z4Gy+M
 HYhd1YvcqPxklCYwo4bO2x6F1SEIdYrPfcpk13954gt4GYvODsCOGLIaOa7QNqwT1b
 KWYLQynJSTkgQ==
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 007BF120FE6;
 Mon,  7 Nov 2022 16:31:34 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <Y2lohC66d/uSi5oz@ACM> (Alan Mackenzie's message of "Mon, 7 Nov
 2022 20:20:20 +0000")
Message-ID: <jwv5yfqv4fx.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM>
Date: Mon, 07 Nov 2022 16:31:32 -0500
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL -0.106 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> (defvar VAR) does not "create a variable".
> According to both its doc string and the Elisp manual it does.

BTW, what I'm describing is how things have worked in `lexical-binding`
since Emacs-24, basically.  A few corner cases didn't quite obey it
(and I'm sure there are still a few remaining ones), but by and large
this is how it has worked for the last 10 years.


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 21:29:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 07 16:29:31 2022
Received: from localhost ([127.0.0.1]:35572 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1os9gQ-0002S0-P6
	for submit <at> debbugs.gnu.org; Mon, 07 Nov 2022 16:29:31 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:22412)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1os9gP-0002Rn-24
 for 59057 <at> debbugs.gnu.org; Mon, 07 Nov 2022 16:29:29 -0500
Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 295258024C;
 Mon,  7 Nov 2022 16:29:23 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9AB9A8043D;
 Mon,  7 Nov 2022 16:29:21 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1667856561;
 bh=K17qnOXenix7GRmIRhkTFgNaxryQHBsWkqVD7d1HX38=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=KpoUjruTvcrKUXNKuo2Cv1L+3sZJ6C4EVLGKz/4MXR3VrEvf+b/ZBShSrse5Ndh2l
 XT9xwfsMAihspOncXFFWfLjyNr1E7mJ5pl/ynDeY/27VytdwBkonnTpyQraIRMLbcL
 Z/AiiF8Fn3t0P3KCP3I07GWJRJBLQl6/76XoKPlWr2BtI/32dvDjWVzG5/sD4yY5B4
 9Eev2xhPhkoSxRfw5cQfGfbdK7qyS6H2fSr2IPtDVakKHUYedWohOB60cr7zgWzX5R
 PAirxK3S20aXmubyIX9sEGVngTqtCUtAODT+L7nXlDjkPYXhtoGpcKTUg9EOibcLpW
 xCyvYO5zQko5Q==
Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 5AB24120F9E;
 Mon,  7 Nov 2022 16:29:21 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <Y2lohC66d/uSi5oz@ACM> (Alan Mackenzie's message of "Mon, 7 Nov
 2022 20:20:20 +0000")
Message-ID: <jwvbkpiv4qh.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM> <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
 <Y2lohC66d/uSi5oz@ACM>
Date: Mon, 07 Nov 2022 16:29:15 -0500
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.037 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

>> (defvar VAR) does not "create a variable".
>
> According to both its doc string and the Elisp manual it does.

Where?  I'm talking specifically about (defvar VAR) not about
`defvar` in general.

>> It just "locally" declares that this identifier should use dynamic
>> scoping when binding a variable.
> Why "locally"?  There's just one obarray involved, which is global.

No, we want to allow `defvar` to have a lexically-local effect.

>> But the better way to write the above code is:
>
>>     (defmacro acm-defvar (var)
>>       `(progn
>>          (defvar ,var)
>>          (eval-when-compile
>>            (when (version-check)
>>              (setq ,var emacs-major-version)))))
>
> There are workarounds, yes.  But surely it would be better to fix the
> bug.

It's not a workaround.  It's how the programmers say whether they want
the (defvar ,var) declaration to affect all the rest of the code or only
the code within the `when`.

Why put the (defvar ,var) within the `when` if not to limit
its scope?


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 20:20:31 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 07 15:20:30 2022
Received: from localhost ([127.0.0.1]:35494 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1os8be-0006x5-HR
	for submit <at> debbugs.gnu.org; Mon, 07 Nov 2022 15:20:30 -0500
Received: from mx3.muc.de ([193.149.48.5]:37949)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1os8bc-0006wn-S5
 for 59057 <at> debbugs.gnu.org; Mon, 07 Nov 2022 15:20:29 -0500
Received: (qmail 21687 invoked by uid 3782); 7 Nov 2022 21:20:20 +0100
Received: from acm.muc.de (p4fe15967.dip0.t-ipconnect.de [79.225.89.103])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Mon, 07 Nov 2022 21:20:20 +0100
Received: (qmail 17820 invoked by uid 1000); 7 Nov 2022 20:20:20 -0000
Date: Mon, 7 Nov 2022 20:20:20 +0000
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
Message-ID: <Y2lohC66d/uSi5oz@ACM>
References: <Y2avmeQhiTntL1q2@ACM>
 <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hello, Stefan.

On Mon, Nov 07, 2022 at 08:07:28 -0500, Stefan Monnier wrote:
> > (defmacro acm-defvar (var)
> >   `(eval-when-compile
> > ;     (when (version-check)
> >        (defvar ,var)
> >        (setq ,var emacs-major-version)
> > ;       )
> >      ))

> (defvar VAR) does not "create a variable".

According to both its doc string and the Elisp manual it does.

> It just "locally" declares that this identifier should use dynamic
> scoping when binding a variable.

Why "locally"?  There's just one obarray involved, which is global.  The
manual says that, with defun, "The variable is marked as "special",
meaning that it should always be dynamically bound.".  In my example
program, l-s-p was created with defvar, yet later in the example, the
compiler bound it lexically.  There is a bug here, either in the code or
in the documentation.

> Before the commit you mentioned, the above (defvar ,var) would sometimes
> incorrectly escape its `when` subexpression and affect subsequent code,
> which is why in the past the presence of `when` did not make much
> difference whereas it now does.

What was incorrect about this "escaping"?  It would appear to match the
elisp manual, and its effect on subsequent code would be positive,
rather than negative, surely?

Why does the `when' now prevent l-s-p being marked as global?  In
particular, why is it not entered into the list
byte-compile-bound-variables?

> Note also that for the same reason the above should arguably never work
> at all since the effect of (defvar ,var) should not escape the
> `eval-when-compile` subexpression.

Why shouldn't it?  The defvar is evaluated at compilation time, should
create l-s-p, and should mark it as dynamically bound.  It does in fact
create the variable (see `message' output), but doesn't mark it as
dynamic when the evaluation is inside a conditional.

> A lot of code relies on this misbehavior, tho, so we still support it.

By what criterion is it "misbehaviour"?  It would appear to be what
defvar's doc string and manual entry say.

> But the better way to write the above code is:

>     (defmacro acm-defvar (var)
>       `(progn
>          (defvar ,var)
>          (eval-when-compile
>            (when (version-check)
>              (setq ,var emacs-major-version)))))

There are workarounds, yes.  But surely it would be better to fix the
bug.

> > This bug doesn't occur on Emacs 28.
> > I have a feeling it was introduced into Emacs 29 very recently.

> The Emacs-28 behavior was a misbehavior, which got fixed accidentally
> recently :-)

I feel I'm beginning to get repetitive here.  ;-)  But what was
incorrect about the Emacs 28 behaviour?  The current behaviour causes
confusing, incorrect warning messages to get output.  It cost me many
hours of labour till I finally found out the warnings came from a change
in the byte compiler.  Surely either the code or the documentation
should be fixed, so that other people don't have to go through the same.

>         Stefan

-- 
Alan Mackenzie (Nuremberg, Germany).




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at 59057 <at> debbugs.gnu.org:


Received: (at 59057) by debbugs.gnu.org; 7 Nov 2022 13:07:41 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 07 08:07:41 2022
Received: from localhost ([127.0.0.1]:33601 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1os1qm-0001kY-T4
	for submit <at> debbugs.gnu.org; Mon, 07 Nov 2022 08:07:41 -0500
Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:40905)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <monnier@HIDDEN>) id 1os1qk-0001kH-Ic
 for 59057 <at> debbugs.gnu.org; Mon, 07 Nov 2022 08:07:39 -0500
Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 73657100189;
 Mon,  7 Nov 2022 08:07:32 -0500 (EST)
Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1])
 by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E8F6A1000F4;
 Mon,  7 Nov 2022 08:07:30 -0500 (EST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca;
 s=mail; t=1667826451;
 bh=vZBiHs7IJcp8MuCxqD/2DtSHY/reaQqvrzkb3o9JPjQ=;
 h=From:To:Cc:Subject:In-Reply-To:References:Date:From;
 b=YkTRMI8Sfae37Xmf5/eOYsQ378pwMknuIOBVxS4jA8uDb4QQOwahpY0yOhrb7KSXr
 W2lOV3TL1XkSCSDIvdeq74FTrrJ/4xTE7Tdj3HJpnBF5a9E5oQSdXmRHrGrhyxi+pY
 2lwQLBarog/omdZMbd5nFYuswziKK1CLtXfXoZ1hvIYw1T8fYPxWATKpZMxkKziZLt
 1o+OeIcIxvP4N1+HaPne5NGgg3iPoL3vjhmCRndPyfmTOOfJRyr1uqwcXawkTTZH4c
 t5SJ+YEpCz63zSHTSHSHCIfOUyY2Ke2LoM9fcAOamJ8BJSNGl3TaH3svaZH35QJHKh
 2l+1nVw1DmCIg==
Received: from pastel (unknown [104.247.241.157])
 by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 8B44F120346;
 Mon,  7 Nov 2022 08:07:30 -0500 (EST)
From: Stefan Monnier <monnier@HIDDEN>
To: Alan Mackenzie <acm@HIDDEN>
Subject: Re: bug#59057: Emacs 29.  Byte compiler sometimes forgets about a
 defvar.
In-Reply-To: <Y2avmeQhiTntL1q2@ACM> (Alan Mackenzie's message of "Sat, 5 Nov
 2022 18:46:49 +0000")
Message-ID: <jwvsfiux6so.fsf-monnier+emacs@HIDDEN>
References: <Y2avmeQhiTntL1q2@ACM>
Date: Mon, 07 Nov 2022 08:07:28 -0500
User-Agent: Gnus/5.13 (Gnus v5.13)
MIME-Version: 1.0
Content-Type: text/plain
X-SPAM-INFO: Spam detection results:  0
 ALL_TRUSTED                -1 Passed through trusted hosts only via SMTP
 AWL 0.090 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DKIM_SIGNED               0.1 Message has a DKIM or DK signature,
 not necessarily valid
 DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature
 DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's
 domain
X-SPAM-LEVEL: 
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 59057
Cc: 59057 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> (defmacro acm-defvar (var)
>   `(eval-when-compile
> ;     (when (version-check)
>        (defvar ,var)
>        (setq ,var emacs-major-version)
> ;       )
>      ))

(defvar VAR) does not "create a variable".  It just "locally" declares
that this identifier should use dynamic scoping when binding a variable.

Before the commit you mentioned, the above (defvar ,var) would sometimes
incorrectly escape its `when` subexpression and affect subsequent code,
which is why in the past the presence of `when` did not make much
difference whereas it now does.

Note also that for the same reason the above should arguably never work
at all since the effect of (defvar ,var) should not escape the
`eval-when-compile` subexpression.  A lot of code relies on this
misbehavior, tho, so we still support it.  But the better way to write
the above code is:

    (defmacro acm-defvar (var)
      `(progn
         (defvar ,var)
         (eval-when-compile
           (when (version-check)
             (setq ,var emacs-major-version)))))

> This bug doesn't occur on Emacs 28.
> I have a feeling it was introduced into Emacs 29 very recently.

The Emacs-28 behavior was a misbehavior, which got fixed accidentally
recently :-)


        Stefan





Information forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 5 Nov 2022 18:47:01 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 05 14:47:01 2022
Received: from localhost ([127.0.0.1]:58021 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1orOC5-0004rZ-DY
	for submit <at> debbugs.gnu.org; Sat, 05 Nov 2022 14:47:01 -0400
Received: from lists.gnu.org ([209.51.188.17]:57544)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <acm@HIDDEN>) id 1orOBz-0004rM-Jq
 for submit <at> debbugs.gnu.org; Sat, 05 Nov 2022 14:46:59 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10])
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1orOBz-0005EH-El
 for bug-gnu-emacs@HIDDEN; Sat, 05 Nov 2022 14:46:55 -0400
Received: from mx3.muc.de ([193.149.48.5])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <acm@HIDDEN>) id 1orOBx-0003TT-GJ
 for bug-gnu-emacs@HIDDEN; Sat, 05 Nov 2022 14:46:55 -0400
Received: (qmail 89263 invoked by uid 3782); 5 Nov 2022 19:46:50 +0100
Received: from acm.muc.de (p4fe153f5.dip0.t-ipconnect.de [79.225.83.245])
 (using STARTTLS) by colin.muc.de (tmda-ofmipd) with ESMTP;
 Sat, 05 Nov 2022 19:46:50 +0100
Received: (qmail 7392 invoked by uid 1000); 5 Nov 2022 18:46:49 -0000
Date: Sat, 5 Nov 2022 18:46:49 +0000
To: bug-gnu-emacs@HIDDEN
Subject: Emacs 29.  Byte compiler sometimes forgets about a defvar.
Message-ID: <Y2avmeQhiTntL1q2@ACM>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
X-Submission-Agent: TMDA/1.3.x (Ph3nix)
From: Alan Mackenzie <acm@HIDDEN>
X-Primary-Address: acm@HIDDEN
Received-SPF: pass client-ip=193.149.48.5; envelope-from=acm@HIDDEN;
 helo=mx3.muc.de
X-Spam_score_int: -18
X-Spam_score: -1.9
X-Spam_bar: -
X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)

Hello, Emacs.

With an up to date master version, start emacs -Q.

(i) Visit bug-compile-defvar.el, which looks like this:

#########################################################################
;; -*- lexical-binding: t -*-

(eval-and-compile
  (defun version-check ()
    (>= emacs-major-version 28)))

(defmacro acm-defvar (var)
  `(eval-when-compile
;     (when (version-check)
       (defvar ,var)
       (setq ,var emacs-major-version)
;       )
     ))

(acm-defvar l-s-p)

(eval-when-compile
  (message
   "\nl-s-p is %sin byte-compile-bound-variables"
   (if (memq 'l-s-p byte-compile-bound-variables)
       "" "not "))
  (message
   "l-s-p is %sbound"
   (if (boundp 'l-s-p) "" "not ")))

(defun acm-bind-l-s-p ()
 (let ((l-s-p emacs-major-version))
   (message "Nothing much\n")))
#########################################################################

The idea here is that the macro acm-defvar itself calls defvar, creating
a variable.

(ii) Do M-x byte-compile-file RET ~/bug-compile-defvar.el.
(iii) Note that this works properly, giving out the two messages, the
  first of which confirms that the new variable l-s-p has been entered
  into the list byte-compile-bound-variables.

(iv) Edit the buffer, removing both single semicolon comment markers, and
  save the file.
(v) Do M-x byte-compile-file RET ~/bug-compile-defvar.el again.
(vi) Note that now the new variable is NOT in
  byte-compile-bound-variables.  This is a bug.
(vii) Note also that there is a spurious compiler warning about l-s-p
  being an unused lexical variable in function acm-bind-l-s-p.  This is
  also a bug.

This bug doesn't occur on Emacs 28.  I have a feeling it was introduced
into Emacs 29 very recently.

-- 
Alan Mackenzie (Nuremberg, Germany).




Acknowledgement sent to Alan Mackenzie <acm@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#59057; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 25 Nov 2022 10:45:01 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.