[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar.
From: |
Stefan Monnier |
Subject: |
bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar. |
Date: |
Mon, 07 Nov 2022 16:29:15 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) |
>> (defvar VAR) does not "create a variable".
>
> According to both its doc string and the Elisp manual it does.
Where? I'm talking specifically about (defvar VAR) not about
`defvar` in general.
>> It just "locally" declares that this identifier should use dynamic
>> scoping when binding a variable.
> Why "locally"? There's just one obarray involved, which is global.
No, we want to allow `defvar` to have a lexically-local effect.
>> But the better way to write the above code is:
>
>> (defmacro acm-defvar (var)
>> `(progn
>> (defvar ,var)
>> (eval-when-compile
>> (when (version-check)
>> (setq ,var emacs-major-version)))))
>
> There are workarounds, yes. But surely it would be better to fix the
> bug.
It's not a workaround. It's how the programmers say whether they want
the (defvar ,var) declaration to affect all the rest of the code or only
the code within the `when`.
Why put the (defvar ,var) within the `when` if not to limit
its scope?
Stefan
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Alan Mackenzie, 2022/11/05
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/07
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/07
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Alan Mackenzie, 2022/11/09
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/09
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Kangas, 2022/11/24
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Eli Zaretskii, 2022/11/24
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Monnier, 2022/11/24
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Stefan Kangas, 2022/11/24
- bug#59057: Emacs 29. Byte compiler sometimes forgets about a defvar., Alan Mackenzie, 2022/11/25