GNU bug report logs -
#59057
Emacs 29. Byte compiler sometimes forgets about a defvar.
Previous Next
Full log
Message #14 received at 59057 <at> debbugs.gnu.org (full text, mbox):
>> (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
This bug report was last modified 2 years and 261 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.