From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stephen Gildea Newsgroups: gmane.emacs.devel Subject: Re: master 11860f8: * test/src/comp-tests.el: Eliminate byte-compiler warnings (Bug#52105). Date: Fri, 26 Nov 2021 20:24:57 -0800 Message-ID: <2586873.1637987097@tigger3.sg.gildea.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="34329"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 27 05:25:56 2021 Return-path: Envelope-to: ged-emacs-devel@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 1mqpHg-0008ik-BK for ged-emacs-devel@m.gmane-mx.org; Sat, 27 Nov 2021 05:25:56 +0100 Original-Received: from localhost ([::1]:51904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mqpHe-0002EM-6h for ged-emacs-devel@m.gmane-mx.org; Fri, 26 Nov 2021 23:25:54 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:57974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqpGy-0001Zg-GR for emacs-devel@gnu.org; Fri, 26 Nov 2021 23:25:12 -0500 Original-Received: from tigger.sg.gildea.net ([99.65.78.170]:50090 helo=tigger3.gildea.net) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mqpGs-00074Q-PE for emacs-devel@gnu.org; Fri, 26 Nov 2021 23:25:11 -0500 Original-Received: from tigger3.sg.gildea.net (localhost [IPv6:::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by tigger3.gildea.net (Postfix) with ESMTPS id 662ED3E0197; Fri, 26 Nov 2021 20:24:57 -0800 (PST) In-Reply-To: Message from monnier@iro.umontreal.ca of 26 Nov 2021 12:27:46 -0500 X-Mailer: MH-E 8.6+git; nmh 1.7.1; GNU Emacs 28.0.60 Content-ID: <2586872.1637987097.1@tigger3.sg.gildea.net> Received-SPF: pass client-ip=99.65.78.170; envelope-from=stepheng+emacs@gildea.com; helo=tigger3.gildea.net 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, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:280287 Archived-At: Stefan Monnier wrote: > > +(eval-when-compile > > + (require 'cl-lib) > > + (require 'comp)) > > +(eval-and-compile > > + (require 'comp-cstr) ;in eval-and-compile for its defstr= uct > > + (defconst comp-test-src (ert-resource-file "comp-test-funcs.el")) > > + (defconst comp-test-dyn-src (ert-resource-file "comp-test-funcs-d= yn.el")) > > + (defconst comp-test-pure-src (ert-resource-file "comp-test-pure.e= l")) > > + (defconst comp-test-45603-src (ert-resource-file "comp-test-45603= .el")) > > + ;; Load the test code here so the compiler can check the function > > + ;; names used in this file. > > + (load comp-test-src nil t) > > + (load comp-test-dyn-src nil t) > > + (load comp-test-pure-src nil t) > > + (load comp-test-45603-src nil t)) > = > This looks pretty ugly, in my book. > = > Were the warnings false positives or were they diagnosing real problem= s? False positives. comp-tests.el compiles some test functions, then examines the result, referring to the test functions by name. The test functions are in resource files, so the compiler thinks they are undefined (and emits warnings) unless the functions are loaded when comp-tests.el is compiled. > The cleanup could start by moving the (require 'comp-cstr) outside of > the `eval-and-compile` since toplevel `require`s are processed both at > compile and run time anyway. I didn't know that. So the "(eval-when-compile (require 'cl-lib))" is wrong, too? Here and in hundreds of other Emacs Lisp files? The test functions here could be loaded with "require" instead of "load", and then they could be moved outside of the "eval-and-compile" form. Would that be more elegant? We could go even further and eliminate the "defconst" forms, calling "ert-resource-file" twice for each file (once here for the "require", and once below for the "native-compile"). That rewrite would eliminate the ugly "eval-and-compile" entirely. < Stephen