From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: tpeplt Newsgroups: gmane.emacs.help Subject: Re: Idiomatic way to avoid unused lexical variable in =?utf-8?B?4oCYZG90aW1lc+KAmQ==?= or =?utf-8?B?4oCYZG9saXN04oCZPw==?= Date: Wed, 27 Mar 2024 01:01:04 -0400 Message-ID: <87il188e0f.fsf@gmail.com> References: <87ttks8wam.fsf@gmail.com> <87msqk8maf.fsf@gmail.com> <87le648h68.fsf@vagabond.tim-landscheidt.de> 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="38402"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: help-gnu-emacs@gnu.org, Stefan Monnier To: Tim Landscheidt Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Wed Mar 27 06:01:40 2024 Return-path: Envelope-to: geh-help-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 1rpLPw-0009qi-9r for geh-help-gnu-emacs@m.gmane-mx.org; Wed, 27 Mar 2024 06:01:40 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rpLPS-0008GY-92; Wed, 27 Mar 2024 01:01:10 -0400 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 1rpLPQ-0008GC-Dm for help-gnu-emacs@gnu.org; Wed, 27 Mar 2024 01:01:08 -0400 Original-Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rpLPO-0006Xo-To for help-gnu-emacs@gnu.org; Wed, 27 Mar 2024 01:01:08 -0400 Original-Received: by mail-qt1-x82f.google.com with SMTP id d75a77b69052e-43107ccd7b9so40237911cf.3 for ; Tue, 26 Mar 2024 22:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1711515666; x=1712120466; darn=gnu.org; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OOtKxjDwY6B5PYsY/xo2kWGsIbwOiJ539QNJNk4jBCI=; b=BmvAZdvprKbYTkT8edKV8OReNQsnviO1e3SeCm6Q+xuNLhtcQqCyZNjrtf9ZPfV67j pD9vru0wiyo/kWMD5kiThRdWk/hw5/+cXxbIVh7jkW7FY4osiDdsUUQEzf2+WPqTQB16 bICj3+ivKN/IXy8y6uvzHEYa/vKi9/IPblg0yJBIRM+8YAMJkk8i+ppOWra+OXd/omfg 3REqAKHoNigli6BC0ja8Xabq7rXF+emFyAY4mMRUV3O0mZHdgfVbp4Wrv4mDkS/TZ0zb lNJzXdoWiWVbjvz5fQvUrp96Etic45KF5ne69lS8L07cu/wOFBOwXQhQDedWMZD/E5pq BdoA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711515666; x=1712120466; h=content-transfer-encoding:mime-version:user-agent:message-id:date :references:in-reply-to:subject:cc:to:from:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=OOtKxjDwY6B5PYsY/xo2kWGsIbwOiJ539QNJNk4jBCI=; b=fCd3TYgbHl9w2yjawH2zpbNbIzWF7NXkTy5R70Jf8Qr3gJ3KAqCn+WZwNYEKdaGEPO Iv/H1zgCVk51isF/N5WCNF2cX312uR+STcOrnYNNEV+T0RNRGhuaP6sv+dTfGFrWMmNZ B+3qywxAFJVZy7/6DnAZZEIrP2iFAN86hYvctrcAGFjtT8Jhl1C1A19ayMkgULqYzmwG oyBBgcdBr7bofrGiZI82nTEaDN2eUX31KAcV4BwxyqCNlHdT2ueo5YqAI7/gQ6s+jtFW 6Hu92EpqLa3pcbPK+IartG43Gx3M2lERPMjCE4JWtu2PnAW5/E0sOBYmHkXKQ+YXLewd gkuA== X-Gm-Message-State: AOJu0YxJ0E8rmiRkjwbFoybYxuNwKDaLlHUC8mj69CXR1BkKL/U5t4cZ 01zt4YwPDA3/TvbXq8/edMyOAjK5vutio17dLd5aBiKoZ+mNJL0/ X-Google-Smtp-Source: AGHT+IE/Ud2afWZZ3vMVbK5d+S/AIAnwVq89xAsuU/Hff9GVzjmhjkspbPHoUhY210CM3vn+rNvbvA== X-Received: by 2002:ac8:5dcd:0:b0:430:e2cb:9a54 with SMTP id e13-20020ac85dcd000000b00430e2cb9a54mr5096426qtx.12.1711515665883; Tue, 26 Mar 2024 22:01:05 -0700 (PDT) Original-Received: from t530.local ([2600:8806:a821:2b00::9361]) by smtp.gmail.com with ESMTPSA id ge11-20020a05622a5c8b00b004309754810fsm4404594qtb.89.2024.03.26.22.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 22:01:05 -0700 (PDT) In-Reply-To: <87le648h68.fsf@vagabond.tim-landscheidt.de> (Tim Landscheidt's message of "Wed, 27 Mar 2024 03:52:47 +0000") Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=tpeplt@gmail.com; helo=mail-qt1-x82f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.help:146182 Archived-At: Tim Landscheidt writes: > >>>> 1. Is there an idiom in Emacs Lisp for writing this that >>>> eliminates this warning? > >>> (dotimes (_ 100) >>> (insert "I will not obey absurd orders\n")) > >>> Or any other var name that starts with an underscore. > >> Thank you. I have not been able to find this documented anywhere (that >> is, that lexical variables whose names begin with an underscore are not >> flagged with a warning message if they are not referenced). This >> appears to be true with, for example, =E2=80=98let=E2=80=99 expressions,= also. > > It is mentioned in the GNU Emacs Lisp Reference Manual (C-h > i g (elisp) RET) in the node "Converting to Lexical > Binding": > > | [=E2=80=A6] > > | A warning about an unused variable may be a good hint that the > | variable was intended to be dynamically scoped (because it is actually > | used, but in another function), but it may also be an indication that > | the variable is simply really not used and could simply be removed. So > | you need to find out which case it is, and based on that, either add a > | =E2=80=98defvar=E2=80=99 or remove the variable altogether. If removal= is not possible > | or not desirable (typically because it is a formal argument and that we > | cannot or don=E2=80=99t want to change all the callers), you can also a= dd a > | leading underscore to the variable=E2=80=99s name to indicate to the co= mpiler > | that this is a variable known not to be used.) > > | [=E2=80=A6] > Again, thank you. This will be useful knowledge in future instances of variables that have to be declared, but are not referenced. --