From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Sun, 08 Dec 2024 09:20:06 +0200 Message-ID: <8634iyhc9l.fsf@gnu.org> 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; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12962"; mail-complaints-to="usenet@ciao.gmane.io" Cc: monnier@iro.umontreal.ca, emacs-devel@gnu.org To: Yuan Fu , Andrea Corallo Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Dec 08 08:20:43 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 1tKBat-0003BO-BG for ged-emacs-devel@m.gmane-mx.org; Sun, 08 Dec 2024 08:20:43 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKBaW-0003wS-0L; Sun, 08 Dec 2024 02:20:20 -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 1tKBaU-0003wF-93 for emacs-devel@gnu.org; Sun, 08 Dec 2024 02:20:18 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tKBaT-00082Q-Ro; Sun, 08 Dec 2024 02:20:17 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=YIm8YTj3Khravst+B/9O2bOioq80VC9L8WvBrSszvT8=; b=n89KQ7vRddWh07BpG3i9 KJzFpGPRhcyUfhb4g5dHuSKqnQgRYxORaypW0+/01wFnSQUPvcACT9EF14OhSDj1LjKYewE5iYfuN Qea6VV+AFZMo79R+eSntbiJUg+1vUvayOKsQsJ0uTbxB0DHVXK4mNBbu/SMChUHHwri2nJ5ry1Wl8 fwypVCqvu3IrY5GbY8ua1mu7hciv5BwLnTFm3VYWyGD0KBuox2jhs2x1iKH+lK3tmSWRDXDGbPUlX tHgxKaSCh92t4WWAcrr9L0jlQVBZBgYb9KxW2qffjETPnWSVhMyXKk5QTlZ9YPpSVAbBXzMCSXA16 GtKFZ+TbedeEog==; In-Reply-To: <292D0D0F-AB88-49AB-86DD-A9B736DB00F7@gmail.com> (message from Yuan Fu on Sat, 7 Dec 2024 22:39:21 -0800) 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:326182 Archived-At: > From: Yuan Fu > Date: Sat, 7 Dec 2024 22:39:21 -0800 > Cc: Eli Zaretskii , > emacs-devel@gnu.org > > > On Dec 7, 2024, at 5:47 AM, Stefan Monnier wrote: > > > >>> Does that mean declare-function forms only affect the file it’s in? > >>> Because if treesit.el has declare-function forms for all the treesit.c > >>> functions, and c-ts-mode.el requires treesit.el, why do we need to have > >>> declare-function forms in c-ts-mode.el? > >> Seems like that. Stefan, am I missing something here? > > > > Yes, `declare-function` *should* follow the same principles as `(defvar > > FOO)`, meaning that they are compiler directives not functions to > > execute. They affect warnings only in the current lexical scope, and > > requiring a file full of `(defvar FOO)` and `declare-function` will have > > no effect at all. > > > > [ Side note regarding this *should*: it currently doesn't work quite as > > well as `defvar` because its effect is always file-wide, whereas it > > should be limited to the current scope. ] > > Defining a macro that contains the declare-function forms, and calling it in eval-when-compile forms seem to work (see patch), WDYT? The name (treesit-declare-c-functions) could be better, any ideas? Looks a bit ugly, but maybe this is the best we can do. Andrea, WDYT?