emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Use (eval-when-compile 'treesit) to save us from writing declare-fun


From: Stefan Monnier
Subject: Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms
Date: Sun, 08 Dec 2024 10:27:19 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> +(eval-when-compile
> +  (treesit-declare-c-functions))

`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`?

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.

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.


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]