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.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Sun, 08 Dec 2024 10:27:19 -0500 Message-ID: References: <2C0B7D3A-6131-4427-BF04-9211981B57DD@gmail.com> <867c8g3o6v.fsf@gnu.org> <0D278D91-4D67-4E0E-869F-6AF0A46678F7@gmail.com> <86h67jz36z.fsf@gnu.org> <502D58B8-9432-4A8F-B50D-ECA392B7E7C5@gmail.com> <86ser2y5e1.fsf@gnu.org> <86ser0j5hw.fsf@gnu.org> <292D0D0F-AB88-49AB-86DD-A9B736DB00F7@gmail.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="33000"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , emacs-devel@gnu.org To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 08 16:28:13 2024 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 1tKJCf-0008Or-I6 for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Dec 2024 16:28:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKJBy-00015x-Di; Sun, 08 Dec 2024 10:27:30 -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 1tKJBw-00015U-0u for emacs-devel@gnu.org; Sun, 08 Dec 2024 10:27:28 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKJBt-0002T7-0V; Sun, 08 Dec 2024 10:27:27 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id B7EEE100134; Sun, 8 Dec 2024 10:27:21 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1733671640; bh=b9Fc4mid4aB4iMF3O1rkcMNaseU/oKwkjWacDl5XEoM=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=prZWPIg4I+N18qcmn85uopOSxz5PZkfky2cj619d5/3X5P31ynaaN0fodg+4w+fJX v28SCr0hhWxclkBgAyFHVISQW9HAmMZt7WnxMDaZczVvdKIfV7OwzsB7JYnFvPZ3g4 OF0wQRI+F7GrVkZWATNR9rxFEvme15U17T0/0LnXkJ3Od0a6phh9abWRFv+8DCq1cP tXdp7QxC7OrFnXzASoSxc/Lojy5TduvXldrlaj30TIqM67VC82qj/y0uuC8KhuuBUi Pgg/VaMTKzLxqOzTFahMii7EqS6AYNQ2Vhc+37pGIfhWp8UPQqa7fs8YWoTLJce9R+ jtHZubAbHhvXA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 7B8521000EF; Sun, 8 Dec 2024 10:27:20 -0500 (EST) Original-Received: from pastel (104-195-225-43.cpe.teksavvy.com [104.195.225.43]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 3E19F1203AB; Sun, 8 Dec 2024 10:27:20 -0500 (EST) In-Reply-To: <292D0D0F-AB88-49AB-86DD-A9B736DB00F7@gmail.com> (Yuan Fu's message of "Sat, 7 Dec 2024 22:39:21 -0800") 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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326194 Archived-At: > +(eval-when-compile > + (treesit-declare-c-functions)) `treesit-declare-c-functions` is a macro, that expands to `declare-function`s, i.e. to "no-ops". Why wrap it within `eval-when-compile`? If it works within an `eval-when-compile`, it's only by accident (just like the fact that (eval-when-compile (defvar foo)) "works" is an accident): code shouldn't rely on it. It's not the evaluation of `defvar` or `declare-function` that is needed (because such an evaluation should have no effect, as you can see if you look at the definition of `declare-function`), but instead the "calls" to `defvar` or `declare-function` need to be seen/processed by the compiler. By wrapping them within an `eval-when-compile` you risk *hiding* them from the compiler. Stefan