vfclists · 2022-12-29 10:51
According to some post I read the behaviour of `defvar` has been changed in that it will set the value of an already set variable if the variable is used again in a `defvar`.
I use `defvar` declarations in order not to get *assignment to free variable* errors and I wouldn't want the existing values to be reset.
I can't find the exact post where I read this but if this is what I think it means it may cause me some problems.
Can anyone clarify it?
ergonaught · 2022-12-29 13:46
My Emacs 29.0.60 does not have such a change.
I wonder if you are thinking of the eval-last-sexp change in Emacs 28, which will re-evaluate defvar now (ex: C-x C-e will re-evaluate this).
pwnedary · 2022-12-29 14:21
I would expect
(defvar foo)
to still do nothing but serve as hint for byte-comp, and
(defvar foo nil)
to now overwrite the value of `foo` if it had been set before. Someone please correct me if this is wrong.
ergonaught · 2022-12-29 14:49
defvar does not overwrite foo if it has already been set.
https://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Variables.html
The exception from Emacs 28 forward seem to be with eval-last-sexp.
pwnedary · 2022-12-29 14:51
Alright, thanks that makes it clear.
vfclists · 2022-12-29 21:06
👍