From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Eli Zaretskii <eliz@gnu.org>
Cc: Yuan Fu <casouri@gmail.com>, Lars Ingebrigtsen <larsi@gnus.org>,
emacs-devel@gnu.org
Subject: Re: Would (Eval-when-compile (require 'treesit)) eliminate the need for (declare-function)s?
Date: Mon, 17 Apr 2023 13:25:26 -0400 [thread overview]
Message-ID: <jwvfs8y77hl.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83fs8ya17i.fsf@gnu.org> (Eli Zaretskii's message of "Mon, 17 Apr 2023 20:05:37 +0300")
>> I’ve made the mistake of forgetting to add (declare-function treesit-xxx)
>> when using functions from treesit.c far too many times (sorry!). Since
>> treesit.el contains declare-function’s for every function in treesit.c, if
>> we use (eval-when-compile (require ’treesit)), would it eliminate the need
>> for adding declare-function’s?
I hope it doesn't: `declare-function` is supposed to affect only the
"current scope", like `(defvar <VAR>)`.
>> Should we do that?
IIUC one way to look at this is that `treesit.el` wants to "re-export"
the functions provided by `treesit.c` so users of `treesit.el` don't
need to know whether the function they call is implemented in C or
in ELisp?
That makes a lot of sense, and I don't think we have a good way to do
that currently :-(
I suspect in most cases we avoid the problem in one of two ways:
- Always define the C function (rather than being conditional on some
compilation flag as is the case for `treesit.c` functions).
- Export from C only "internal functions" so all the non-internal API is
implemented in ELisp.
> Even if it does work reliably, I'm not sure we want that. It is
> better to have declare-function where the function is used, as that
> makes maintenance easier and less error-prone.
But it makes sense for packages that do
(require 'treesit)
to be able to use those functions implemented in `treesit.c` without
bothering with `declare-function`.
Stefan
next prev parent reply other threads:[~2023-04-17 17:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-17 3:12 Would (Eval-when-compile (require 'treesit)) eliminate the need for (declare-function)s? Yuan Fu
2023-04-17 3:31 ` Ruijie Yu via Emacs development discussions.
2023-04-17 13:29 ` Philip Kaludercic
2023-04-17 17:05 ` Eli Zaretskii
2023-04-17 17:25 ` Stefan Monnier [this message]
2023-04-17 17:39 ` Eli Zaretskii
2023-04-18 17:46 ` Yuan Fu
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=jwvfs8y77hl.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=larsi@gnus.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.