GNU bug report logs -
#76748
31.0.50; `unload-feature' unbinds NEW-ALIAS and BASE-VARIABLE of variable alias
Previous Next
Reported by: Jens Schmidt <jschmidt4gnu <at> vodafonemail.de>
Date: Tue, 4 Mar 2025 20:58:02 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
On 2025-03-12 23:53, Stefan Monnier wrote:
> You could also choose to keep that function "internal"
> and not document it in the manual/NEWS (like we did for
> `internal-make-var-non-special`), mostly justified in case its
> semantics is delicate/messy/ugly.
I decided to do exactly that - if anybody else except `unload-feature'
is ever going to need that function, she/he can do the documentation.
Will add some tests, anyway, when the rest of this has been decided
upon.
Adding the function `internal-delete-indirect-variable' and calling it
from loadhist.el was easy enough (too easy?), please see the attached
patch for a first draft. I decided that the right way to unbind an
alias, as far as `unload-feature' is concerned, is to make it a regular
variable and unbind that.
More questions:
1. I have a bad feeling about butting in between 1st class citizens
makunbound and fmakunbound in data.c, but couldn't find a better
other place for that function.
2. Before or after switching the variable from an alias to a plain one
in `internal-delete-indirect-variable', do I somehow need to clean or
zero ...val->alias before overwriting it as ...val->value with
"Fset (symbol, Qunbound);"?
3. defvaralias attaches the new alias to the load history as symbol.
One could also attach it as (Fcons (Qalias, new_alias)) and provide a
new cl method loadhist-unload-element for that case instead of handling
aliases together with regular symbols.
Finally, `defvaralias' and `define-obsolete-variable-alias' have a
number of other side-effects, which I have not covered in function
`internal-delete-indirect-variable'. Please let me know if I should
care about any of these:
4. defvaralias potentially calls
notify_variable_watchers (new_alias, base_variable, Qdefvaralias, Qnil);
5. defvaralias declares both new alias and base symbol as special.
6. defvaralias sets
XSYMBOL (new_alias)->u.s.trapped_write =
XSYMBOL (base_variable)->u.s.trapped_write;
7. defvaralias puts the alias docstring into the variable-documentation
property.
8. define-obsolete-variable-alias copies properties `saved-value',
`saved-variable-comment' from the obsolete to the non-obsolete
symbol.
9. define-obsolete-variable-alias sets property `byte-obsolete-variable'
on the obsolete symbol.
Thanks.
[0001-Correctly-unload-variable-aliases.patch (text/x-patch, attachment)]
This bug report was last modified 67 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.