From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.help Subject: Re: How to avoid compiler warning `unused lexical variable' for `dolist' or `dotimes'? Date: Sat, 09 Jan 2021 14:01:54 -0500 Message-ID: References: <87zh1kq97s.fsf@robertthorpeconsulting.com> <87czyekkfd.fsf@logand.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18038"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: help-gnu-emacs@gnu.org To: Tomas Hlavaty Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sat Jan 09 20:02:56 2021 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 1kyJVn-0004YF-EK for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 20:02:55 +0100 Original-Received: from localhost ([::1]:50058 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kyJVm-0000iL-Fu for geh-help-gnu-emacs@m.gmane-mx.org; Sat, 09 Jan 2021 14:02:54 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57664) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyJUw-0000i9-9G for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 14:02:02 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:52060) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kyJUu-0002Ta-5r for help-gnu-emacs@gnu.org; Sat, 09 Jan 2021 14:02:01 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 6301E440C3A; Sat, 9 Jan 2021 14:01:57 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 0E23C440C19; Sat, 9 Jan 2021 14:01:56 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1610218916; bh=R3xssurASXXQClRSGsQN2xFXxV56J1IfhxzSgi9mbX0=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=L1i6Lc33P+Odx8Ix057VkyfRAXNhd+lUipbh7BjH6LAt7G7NMmnZOAlC8MhCLKB91 Q6QkezXhEr/eHMoA9tCcwgpKk+y5C/0h1CREGYbt2xoSpyoSKi6ojPqpvC3gIsRnGT NVulCS/Ir+/Yt3iyyjVB5FhMqWX/RAz6FyyyisCm4jRJgu8qNGOlaeXVwmF3QI7Dgb uM8GERv2Mu1mtHAVYXRwjE+giPsTP4YA2ALjD8EfFKIJ5wZ6TLfJbqoOik0Bj+p7nF 63Sjr3w7r0vFKW2eT3lr58tZ8IfPyFRXKG9LgqSV2Cgry1NZJypevfgYmUyQPq0VNd W72ivi7xYLk1Q== Original-Received: from alfajor (unknown [45.72.224.181]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id CC183120371; Sat, 9 Jan 2021 14:01:55 -0500 (EST) In-Reply-To: <87czyekkfd.fsf@logand.com> (Tomas Hlavaty's message of "Sat, 09 Jan 2021 19:57:26 +0100") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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.23 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" Xref: news.gmane.io gmane.emacs.help:127147 Archived-At: >> (let ((i --dotimes-counter--)) plist)) > > In Common Lisp, that part would be solved by (declare (ignorable i)) in > the macro: > > (let ((i --dotimes-counter--)) > (declare (ignorable i)) > plist) > > I do not know if Emacs Lisp has ignorable. We have something equivalent: (let ((i --dotimes-counter--)) (ignore i) plist) [ Which "comes for free" in the sense that it is not the result of deliberate design but rather the simple fact that the `ignore` function is usually optimized away (but it's optimized late enough that the `i` passed to it still counts as a use of that variable). ] >> You won't get this warning if you do: >> >> (dotimes (i length (progn (ignore i) plist)) >> (setf plist (plist-put plist (intern (elt columns i)) (elt values i)))) >> or >> (dotimes (i length) >> (setf plist (plist-put plist (intern (elt columns i)) (elt values i)))) >> plist > > This is just moving the problem from macro author to macro users. Indeed, and it reflects the fact that some of those who get to decide (e.g. yours truly) don't like this 3rd arg. Stefan