From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 69290@debbugs.gnu.org
Subject: bug#69290: declare-function doesn't work when combined with --eval and -batch
Date: Wed, 21 Feb 2024 00:28:46 +0300 [thread overview]
Message-ID: <53767a63f52ce77960e41d07cdfd40c4eaad75d4.camel@yandex.ru> (raw)
In-Reply-To: <c77057ced619e6e711f9d4b3d707f3f230767e21.camel@yandex.ru>
On Tue, 2024-02-20 at 23:31 +0300, Konstantin Kharlamov wrote:
> On Tue, 2024-02-20 at 22:20 +0200, Eli Zaretskii wrote:
> > > From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> > > Cc: 69290@debbugs.gnu.org
> > > Date: Tue, 20 Feb 2024 23:13:27 +0300
> > >
> > > > Does --eval '(declare-function hello nil)' tell anything to the
> > > > byte-compiler?
> > >
> > > Well, I can guess by the way you're asking that the answer is
> > > "no",
> > > but
> > > I have no idea why so. It should.
> >
> > How can it? The declare-function form is evaluated by the startup
> > code, and only after that the byte-compiler is invoked to compile
> > test.el. At least this is my analysis of what happens here.
> >
> > > 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).
> >
> > For the declare-function form to take effect, the byte-compiler
> > needs
> > to evaluate the form. 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.
Btw, I just figured out how to show you why this doc-string doesn't say
anything on the matter. Imagine for a second that `declare-function` is
getting through from "eval" to the byte-compiler, i.e. the problem
we're discussing is just not present. Would you change the string `Tell
the byte-compiler that function FN is defined` to something else in
this case? I would not, because it's still byte-compiler that does all
the checking, so the point that "declare-function" is purposed for
`byte-compiler` stands.
next prev parent reply other threads:[~2024-02-20 21:28 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-20 18:59 bug#69290: declare-function doesn't work when combined with --eval and -batch Konstantin Kharlamov
2024-02-20 19:51 ` Eli Zaretskii
2024-02-20 19:56 ` Konstantin Kharlamov
2024-02-20 20:03 ` Eli Zaretskii
2024-02-20 20:13 ` Konstantin Kharlamov
2024-02-20 20:20 ` Eli Zaretskii
2024-02-20 20:31 ` Konstantin Kharlamov
2024-02-20 21:28 ` Konstantin Kharlamov [this message]
2024-02-21 3:30 ` Eli Zaretskii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53767a63f52ce77960e41d07cdfd40c4eaad75d4.camel@yandex.ru \
--to=hi-angel@yandex.ru \
--cc=69290@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.