From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#69290: declare-function doesn't work when combined with --eval and -batch Date: Tue, 20 Feb 2024 23:31:53 +0300 Message-ID: References: <868r3eoqw0.fsf@gnu.org> <2f376e6d58b58f3fa8afa5376018a37b1ba3fab4.camel@yandex.ru> <867ciyoqc4.fsf@gnu.org> <7c6965eaa2f67eaba8128228033dc0b0d0efb42b.camel@yandex.ru> <865xyiopkn.fsf@gnu.org> Mime-Version: 1.0 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="25458"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Evolution 3.50.3 Cc: 69290@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Feb 20 21:32:58 2024 Return-path: Envelope-to: geb-bug-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 1rcWnQ-0006Md-L4 for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 20 Feb 2024 21:32:56 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rcWnC-0007fS-A6; Tue, 20 Feb 2024 15:32:42 -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 1rcWnA-0007fJ-Tx for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 15:32:40 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rcWnA-0001fn-L1 for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 15:32:40 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rcWnV-0003vD-UB for bug-gnu-emacs@gnu.org; Tue, 20 Feb 2024 15:33:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 20 Feb 2024 20:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69290 X-GNU-PR-Package: emacs Original-Received: via spool by 69290-submit@debbugs.gnu.org id=B69290.170846117415063 (code B ref 69290); Tue, 20 Feb 2024 20:33:01 +0000 Original-Received: (at 69290) by debbugs.gnu.org; 20 Feb 2024 20:32:54 +0000 Original-Received: from localhost ([127.0.0.1]:46780 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcWnO-0003us-64 for submit@debbugs.gnu.org; Tue, 20 Feb 2024 15:32:54 -0500 Original-Received: from forward500a.mail.yandex.net ([178.154.239.80]:55654) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rcWnI-0003uf-Kb for 69290@debbugs.gnu.org; Tue, 20 Feb 2024 15:32:52 -0500 Original-Received: from mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net [IPv6:2a02:6b8:c0d:2a02:0:640:77d9:0]) by forward500a.mail.yandex.net (Yandex) with ESMTPS id CFF3061441; Tue, 20 Feb 2024 23:31:54 +0300 (MSK) Original-Received: by mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id rVYD28jWruQ0-EmrAtPAL; Tue, 20 Feb 2024 23:31:54 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1708461114; bh=EUSR1Po6yOplXpeE2lmDSGoVflfQt4hMSHwBeq6xKxM=; h=References:Date:In-Reply-To:Cc:To:From:Subject:Message-ID; b=pvMOesK83CoahadKpM0RVTtypNG4/XAeGGlCSi1z7OQfPa+RHYmVVDzewvua7Y0fm Bt31qI8YAqmUMW2z6dOzIRfGyOYTmGJUGMN4dm7XEA2f+9HF/7rCiLLJ/sgYrObpqr g+DmDiG5FhM1lskiCaYSHzMtjX4zqcJQju6ZvW10= Authentication-Results: mail-nwsmtp-smtp-production-main-51.vla.yp-c.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: <865xyiopkn.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280359 Archived-At: On Tue, 2024-02-20 at 22:20 +0200, Eli Zaretskii wrote: > > From: Konstantin Kharlamov > > Cc: 69290@debbugs.gnu.org > > Date: Tue, 20 Feb 2024 23:13:27 +0300 > >=20 > > > Does --eval '(declare-function hello nil)' tell anything to the > > > byte-compiler? > >=20 > > Well, I can guess by the way you're asking that the answer is "no", > > but > > I have no idea why so. It should. >=20 > How can it?=C2=A0 The declare-function form is evaluated by the startup > code, and only after that the byte-compiler is invoked to compile > test.el.=C2=A0 At least this is my analysis of what happens here. >=20 > > It is the same as if you pop up Emacs, evaluate a (defun hello()) > > and then call `byte-compile-file` over the `test.el`. There won't > > be > > a warning, despite that `(defun hello ())` was never byte-compiled > > (AFAIK Emacs does note byte-compile evaluated code). >=20 > For the declare-function form to take effect, the byte-compiler needs > to evaluate the form.=C2=A0 By contrast, defun is evaluated by the Lisp > interpreter and the result is stored in the global state. Oh, thank you for explanation, I see. It's doesn't seem to be obvious to a bystander, because from the side it seems like in Emacs byte- compiler and interpreter should work in a tandem, as in the example with evaluating (defun hello()). In Emacs context the doc-string that says `Tell the byte-compiler that function FN is defined` would read to me as "modify global state, which later will be read by byte-compiler to deem FN as defined". IOW, to me as a bystander the documentation string does not explain the difference, which is why we just had this somewhat long discussion before I understood why `declare-function` works this way. I guess the bug can be closed, sorry for the noise.