From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Matt Armstrong Newsgroups: gmane.emacs.bugs Subject: bug#58801: [PATCH] Autoload the `calc-eval-error' variable Date: Tue, 15 Nov 2022 10:24:00 -0800 Message-ID: <8735ak6pq7.fsf@rfc20.org> References: <87fsfaa56t.fsf@rfc20.org> 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="36046"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 58801@debbugs.gnu.org To: Stefan Kangas Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Nov 15 19:25:18 2022 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 1ov0cX-00099l-Pd for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 15 Nov 2022 19:25:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ov0cO-0000eP-K7; Tue, 15 Nov 2022 13:25:09 -0500 Original-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 ) id 1ov0cJ-0000eA-5P for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 13:25:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ov0cI-0003kH-Sm for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 13:25:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ov0cI-0004Ie-GK for bug-gnu-emacs@gnu.org; Tue, 15 Nov 2022 13:25:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Matt Armstrong Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 15 Nov 2022 18:25:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58801 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 58801-submit@debbugs.gnu.org id=B58801.166853665316465 (code B ref 58801); Tue, 15 Nov 2022 18:25:02 +0000 Original-Received: (at 58801) by debbugs.gnu.org; 15 Nov 2022 18:24:13 +0000 Original-Received: from localhost ([127.0.0.1]:55211 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov0bU-0004HU-OI for submit@debbugs.gnu.org; Tue, 15 Nov 2022 13:24:13 -0500 Original-Received: from relay9-d.mail.gandi.net ([217.70.183.199]:42167) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ov0bS-0004HF-Cj for 58801@debbugs.gnu.org; Tue, 15 Nov 2022 13:24:11 -0500 Original-Received: (Authenticated sender: matt@rfc20.org) by mail.gandi.net (Postfix) with ESMTPSA id 96EE5FF80B; Tue, 15 Nov 2022 18:24:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rfc20.org; s=gm1; t=1668536644; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Jw6mFbpHn5fsEYv6MXT7ex5TMCZw3UAEyw+hgKlP0wg=; b=TMZ7W2b/So6bn+Ww43bSX5G+YinrP5ZTXn2ObbtzTZFfeANkoR07/Pa/yKfPsWS+i/RIwq o44KQAGcubLvrafOqdYzWpvJA7P8jSfsOyiptJ4MVtkhQFJrHO88/96iZgE8CdQShrPbdl kdsdBC/WwwoLo6ssvSua49GGAjDTJIaYdWS5f0XDJlhDZLrTiV8pzDiz57+a5Z83SDkHlW //6GEZHANkm/W/0aUyDwo4PRLp7q7QltlPtjex1g0mr/TS8zVnT9iauTvOL+DwSnicEPKo MBGb8VPuPYNwp/DMihgbrl/SkDhP31gIx20uSisD08ujnsPH7T64lOuwpF12Ag== Original-Received: from matt by naz with local (Exim 4.96) (envelope-from ) id 1ov0bI-000QVZ-14; Tue, 15 Nov 2022 10:24:00 -0800 In-Reply-To: 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:247963 Archived-At: Stefan Kangas writes: > Matt Armstrong writes: > >> From 526d0b31e0d836e7a3c21d831849b8c50da2420e Mon Sep 17 00:00:00 2001 >> From: Matt Armstrong >> Date: Wed, 26 Oct 2022 09:46:37 -0700 >> Subject: [PATCH] Autoload the `calc-eval-error' variable >> >> * lisp/calc/calc-aent.el: Autoload the `calc-eval-error' variable, >> because it is documented as a lisp level option of the `calc-eval' >> function, which is also autoloaded. Otherwise, even (require 'calc) >> is not enough to get the variable defined; `calc-eval' must actually >> be evaluated. This squashes byte compiler warnings in code using the >> variable. > > I don't necessarily object strongly or anything, but should we really > autoload a variable just to squash byte compiler warnings? Perhaps I can learn something here. Why refrain from autoloading the variable in this situation? Note that in my case I had (require 'calc) in the file that used the `calc-eval-error' symbol. The info docs for calc state that (require 'calc) loads nearly everything you need from calc. I may not understand something about the design constraints here, but it seems strange to refrain from autoloading this symbol, since (require 'calc) already (auto)loads a *lot* of stuff. > I think the usual way to do that is to say > > (defvar calc-eval-error) > > in the calling code. I think "in the calling code" applies to specific situations. For example: - A defvar for something x- in package x. - Symbols provided by packages that are conditionally loaded, so the current package can not rely on (require 'x) to providing `x-' symbols at bytcomp time. - Situations where the package has inadequate/incorrect autoloads, so (require 'x) doesn't provide enough. I.e. to work around bugs. ;-) My first impression is that adding `defvar' to squash bytecomp warnings for symbols in other packages is the wrong default action, and that the best idea is for (require 'foo) to provide all symbols 'foo-' that one might need when using the `foo' package in the normal way. Notice that (info "(elisp) Converting to Lexical Binding") has this phrasing: > A warning about a reference or an assignment to a free variable is > usually a clear sign that that variable should be marked as > dynamically scoped, so you need to add an appropriate =E2=80=98defvar=E2= =80=99 before > the first use of that variable. It doesn't state what an "appropriate 'defvar'" is. Certainly, if the var is part of the current package, adding a 'defvar' in the same file makes sense. If the var is part of some other package, properly required by the current package, I think that other package is missing an autoload.