[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#5450: Variable Capturing and other problems in assoc.el
From: |
Michael Heerdegen |
Subject: |
bug#5450: Variable Capturing and other problems in assoc.el |
Date: |
Fri, 22 Jan 2010 18:53:01 +0100 |
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.
- bug#5450: Variable Capturing and other problems in assoc.el,
Michael Heerdegen <=