From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms Date: Sun, 8 Dec 2024 17:37:59 -0800 Message-ID: <1771C735-A03F-4FE5-8FCE-22F9647F4C36@gmail.com> 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 (Mac OS X Mail 16.0 \(3776.700.51\)) 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="20731"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Dec 09 02:39:16 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 1tKSk0-0005FV-1J for ged-emacs-devel@m.gmane-mx.org; Mon, 09 Dec 2024 02:39:16 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tKSj2-0007FY-5j; Sun, 08 Dec 2024 20:38:16 -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 1tKSj1-0007FQ-Cu for emacs-devel@gnu.org; Sun, 08 Dec 2024 20:38:15 -0500 Original-Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tKSiz-0008Dr-PS; Sun, 08 Dec 2024 20:38:15 -0500 Original-Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-725ad59ad72so2547245b3a.2; Sun, 08 Dec 2024 17:38:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733708292; x=1734313092; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=iLOVlK+5zLuweQxyjALeDy+oMbIHwcNqZD/AJFRtI1M=; b=dd9wc6s129Vax4UnWOJ7y33OiFXZ3Nr5JRtcsAG1iQ9x/viDQhDc8/hSVC2zpx4fzQ sI3DtHbztMF+HgTKj/OVcWWaJ00d7V8S/JzpUh/nUeSgWkJQ6fFDKOnvnLMZSMg6E8Zh yLQTmj0l4FNS8Q26UlLUt588al37BAfA/Np56wnqzPIYeR44Dpgfw5KF1Ht/7NvYAJC5 JJHSlZ5y+OX1g38IZGaM0IKTF2m2s0JaQSEXeDhAEG6TLK+mc0NgGc93e636AO6cQTnb oiOo0NkbC+5qoTilk6k2O7Q9WZhVsreevr7NhxfP1W3P622MPp7nNk+X1hqTi8R8mwi5 neyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733708292; x=1734313092; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iLOVlK+5zLuweQxyjALeDy+oMbIHwcNqZD/AJFRtI1M=; b=m0aF+gsbA3WaPlODnl/uvQsg8B9AVZYVH7wl1taMx2gLZobRn+aNE5ZvunIuhG8aUL z6JXujXyET2uH6GSUEOYA+1Rqsp2MaJ5u6n75qbIyUheupi85aRzflVq0JXcVcFNIzvV B66GRcFG/mhsSErt2imEdnVv1vrPg1iylM/7f+6dtN18tJt/GX6mknruDC3NFflJdaUK zH1RWGO9pXqjLs/0RQnsolhTeD//WnTM6g9eb4pZvcJY4aGz2z/uo9zf1kZ4GBZmYMO3 i9SUfnLUdKU1182bYDZHtv8pSz/B3AZxtsPU+hUF7Bn8Z4a82l330zIs8hI/jhaDH2sW ntBg== X-Forwarded-Encrypted: i=1; AJvYcCV/A4gWp0/G2wMlO2yn4+jjK6X7fTeVTBcYi/CcYyDldY/Ek2GRZ7iX7MR7UYGIMOwZ/V6I8jM6vec9PA==@gnu.org X-Gm-Message-State: AOJu0YyYlKnzH3quGvq/fNhcE9rXLTglyDQuKPfzCrKQ1aRWNpcu6lzO ltpb5pV6BJlhJvqWCPN0QP3n+QIsgJoBp8nnHu1HRlrdpVfrpSva X-Gm-Gg: ASbGncuWIZSmT05jVcPrR5qeym7ST5cxZgn/X+SqQvORbBZhTrUOlBL/0pPho8Mvtg3 tL5P5tTTyvm5Q6UFHctTmKl/+nMrLcx/E2gL5DAbwgEE06/4roRiFykCPcF7SaSsd8kseSx9oHo 8WhjiJbKVyqQyo5U/xNK4nUfGiUyGNMf/7HvfqyHDPRYsw7LfnCZJCEHvM6cExyaIXs7zLNyIBE vUZaWpvvwMI3J/CexfpV03YJQThnZbfTVUEtWcp8dPt/SLpZt8BFLTeJLYzabstIijXQZbCEQ== X-Google-Smtp-Source: AGHT+IGjCu1jmSFA3RT/SyPqjGvBUaK+7G5ZktICYIw7+3Y+UdlBfl7InPtaC0C7r5gligEGGTaWhQ== X-Received: by 2002:a05:6a20:72a3:b0:1e1:ac71:2b6a with SMTP id adf61e73a8af0-1e1ac713f01mr1016568637.28.1733708291624; Sun, 08 Dec 2024 17:38:11 -0800 (PST) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:d59e:a328:96f3:f483]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-725e67c2759sm1509633b3a.17.2024.12.08.17.38.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Dec 2024 17:38:11 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) Received-SPF: pass client-ip=2607:f8b0:4864:20::430; envelope-from=casouri@gmail.com; helo=mail-pf1-x430.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: 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:326222 Archived-At: > On Dec 8, 2024, at 7:27=E2=80=AFAM, Stefan Monnier = wrote: >=20 >> +(eval-when-compile >> + (treesit-declare-c-functions)) >=20 > `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`? I thought that might be TRT since they=E2=80=99re only needed for = compiling the file. >=20 > 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. >=20 > 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. I thought eval-when-compile is more of a =E2=80=9Cinclude if = compiling=E2=80=9D macro, should=E2=80=99ve checked :) We can also go with Dmitry=E2=80=99s idea, and just define all the = functions in treesit.el if Emacs is not built with tree-sitter. We can = detect that with treesit-available-p. Yuan=