[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
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, (continued)
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/04
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/04
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/05
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/05
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/06
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/07
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/07
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Andrea Corallo, 2024/12/11
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms,
Stefan Monnier <=
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/10
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Stefan Monnier, 2024/12/13
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/08
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Andrea Corallo, 2024/12/11
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Dmitry Gutov, 2024/12/11
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/12
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Eli Zaretskii, 2024/12/12
- Re: Use (eval-when-compile 'treesit) to save us from writing declare-function forms, Yuan Fu, 2024/12/13