* bug#5450: Variable Capturing and other problems in assoc.el
@ 2010-01-22 17:53 Michael Heerdegen
2010-01-23 22:46 ` Chong Yidong
0 siblings, 1 reply; 2+ messages in thread
From: Michael Heerdegen @ 2010-01-22 17:53 UTC (permalink / raw)
To: bug-gnu-emacs
Hello,
In the code of assoc.el, local variables in the functions `aput',
`adelete' and `amake' may hide the alist-symbol in the `eval'-clauses,
which produces wrong results.
Example:
(tested with my Emacs 22 -Q, and also with the current CVS version of
assoc.el):
ELISP> (require 'assoc)
assoc
ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (aput 'alist "a" 123456)
(("a" . 123456))
ELISP> (aput 'blist "a" 123456)
("a" . 123456)
ELISP> alist
(("a" . 1)
("b" . 2))
ELISP> blist
(("a" . 123456)
("b" . 2))
------
ELISP> (setq alist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (setq blist '(("a" . 1) ("b" . 2)))
(("a" . 1)
("b" . 2))
ELISP> (adelete 'alist "a")
(("b" . 2))
ELISP> (adelete 'blist "a")
(("b" . 2))
ELISP> alist
(("a" . 1)
("b" . 2))
ELISP> blist
(("b" . 2))
---
Another thing: the doc of `aelement' is misleading in my opinion:
aelement is a compiled Lisp function in `assoc.el'.
(aelement KEY VALUE)
Makes a list of a cons cell containing car of KEY and cdr of VALUE.
The returned list is suitable as an element of an alist.
The returned value is an one element list with a cons cell, suitable
for `nconc', but not directly as an element of an alist.
---
It is also not fine that `amake' doesn't assign to unbound symbols:
ELISP> (amake 'clist '("a" "b") '(1 2))
*** Eval error *** Symbol's value as variable is void: clist
so the package misses a real alist constructor.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-01-23 22:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-01-22 17:53 bug#5450: Variable Capturing and other problems in assoc.el Michael Heerdegen
2010-01-23 22:46 ` Chong Yidong
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.