From mboxrd@z Thu Jan  1 00:00:00 1970
Path: news.gmane.org!not-for-mail
From: Michael Heerdegen <michael_heerdegen@web.de>
Newsgroups: gmane.emacs.bugs
Subject: bug#5450: Variable Capturing and other problems in assoc.el
Date: Fri, 22 Jan 2010 18:53:01 +0100
Message-ID: <1264182781.19724.4389@snow>
NNTP-Posting-Host: lo.gmane.org
X-Trace: ger.gmane.org 1264183835 4293 80.91.229.12 (22 Jan 2010 18:10:35 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Fri, 22 Jan 2010 18:10:35 +0000 (UTC)
To: bug-gnu-emacs@gnu.org
Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jan 22 19:10:28 2010
Return-path: <bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org>
Envelope-to: geb-bug-gnu-emacs@m.gmane.org
Original-Received: from lists.gnu.org ([199.232.76.165])
	by lo.gmane.org with esmtp (Exim 4.50)
	id 1NYNxg-00051h-Rc
	for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jan 2010 19:10:25 +0100
Original-Received: from localhost ([127.0.0.1]:56872 helo=lists.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43)
	id 1NYNxh-0000O0-Ps
	for geb-bug-gnu-emacs@m.gmane.org; Fri, 22 Jan 2010 13:10:25 -0500
Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NYNx3-00005M-3x
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 13:09:45 -0500
Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NYNwy-0008Up-8l
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 13:09:44 -0500
Original-Received: from [199.232.76.173] (port=52082 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NYNwy-0008Ui-5B
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 13:09:40 -0500
Original-Received: from debbugs.gnu.org ([140.186.70.43]:52134)
	by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32)
	(Exim 4.60) (envelope-from <Debian-debbugs@debbugs.gnu.org>)
	id 1NYNwx-0003yG-Qk
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 13:09:39 -0500
Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69)
	(envelope-from <Debian-debbugs@debbugs.gnu.org>)
	id 1NYNvO-0001jD-0r; Fri, 22 Jan 2010 13:08:02 -0500
X-Loop: bug-gnu-emacs@gnu.org
Mail-Followup-To: michael_heerdegen@web.de, 5450@debbugs.gnu.org
Resent-From: Michael Heerdegen <michael_heerdegen@web.de>
Original-Sender: debbugs-submit-bounces@debbugs.gnu.org
Resent-To: owner@debbugs.gnu.org
Resent-CC: bug-gnu-emacs@gnu.org
Resent-Date: Fri, 22 Jan 2010 18:08:01 +0000
Resent-Message-ID: <handler.5450.B.12641836366624@debbugs.gnu.org>
Resent-Sender: bug-gnu-emacs@gnu.org
X-Emacs-PR-Message: report 5450
X-Emacs-PR-Package: emacs
X-Emacs-PR-Keywords: 
Original-Received: via spool by submit@debbugs.gnu.org id=B.12641836366624
	(code B ref -1); Fri, 22 Jan 2010 18:08:01 +0000
Original-Received: (at submit) by debbugs.gnu.org; 22 Jan 2010 18:07:16 +0000
Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
	id 1NYNue-0001in-Cp
	for submit@debbugs.gnu.org; Fri, 22 Jan 2010 13:07:16 -0500
Original-Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <Michael_Heerdegen@web.de>) id 1NYNhV-0001aH-Sq
	for submit@debbugs.gnu.org; Fri, 22 Jan 2010 12:53:42 -0500
Original-Received: from mail.gnu.org ([199.232.76.166]:48026 helo=mx10.gnu.org)
	by fencepost.gnu.org with esmtp (Exim 4.69)
	(envelope-from <Michael_Heerdegen@web.de>) id 1NYNhR-0002q6-EP
	for submit@debbugs.gnu.org; Fri, 22 Jan 2010 12:53:37 -0500
Original-Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim
	4.60) (envelope-from <Michael_Heerdegen@web.de>) id 1NYNhQ-0000On-CI
	for submit@debbugs.gnu.org; Fri, 22 Jan 2010 12:53:37 -0500
Original-Received: from lists.gnu.org ([199.232.76.165]:54251)
	by monty-python.gnu.org with esmtps
	(TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60)
	(envelope-from <Michael_Heerdegen@web.de>) id 1NYNhQ-0000Of-5z
	for submit@debbugs.gnu.org; Fri, 22 Jan 2010 12:53:36 -0500
Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43)
	id 1NYNhP-00007B-R5
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 12:53:35 -0500
Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43)
	id 1NYNhK-0008WF-Qx
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 12:53:35 -0500
Original-Received: from [199.232.76.173] (port=56165 helo=monty-python.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.43) id 1NYNhK-0008W4-KG
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 12:53:30 -0500
Original-Received: from fmmailgate02.web.de ([217.72.192.227]:44715)
	by monty-python.gnu.org with esmtp (Exim 4.60)
	(envelope-from <Michael_Heerdegen@web.de>) id 1NYNhJ-0000Li-Vv
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 12:53:30 -0500
Original-Received: from smtp08.web.de (fmsmtp08.dlan.cinetic.de [172.20.5.216])
	by fmmailgate02.web.de (Postfix) with ESMTP id 2D20714C56458
	for <bug-gnu-emacs@gnu.org>; Fri, 22 Jan 2010 18:53:25 +0100 (CET)
Original-Received: from [217.185.137.14] (helo=snow)
	by smtp08.web.de with asmtp (WEB.DE 4.110 #314) id 1NYNhE-0008Tf-00
	for bug-gnu-emacs@gnu.org; Fri, 22 Jan 2010 18:53:24 +0100
X-Sender: michael_heerdegen@web.de
X-Provags-ID: V01U2FsdGVkX1/ZDfOa+6X81q9YkrFPdCOMEBO2R59alaIxN0Rb
	1g6cf9nr5gPhDfEh2JTCWZSTzF1XKb1Rg8wtUurzU0WSIzecgu
	arW1sIBzVxifeL1JOQiQ==
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.4-2.6
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6,
	seldom 2.4 (older, 4)
X-Spam-Score: -6.6 (------)
X-Mailman-Approved-At: Fri, 22 Jan 2010 13:07:14 -0500
X-BeenThere: debbugs-submit@debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
X-Spam-Score: -6.6 (------)
Resent-Date: Fri, 22 Jan 2010 13:08:02 -0500
X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3)
X-BeenThere: bug-gnu-emacs@gnu.org
List-Id: "Bug reports for GNU Emacs,
	the Swiss army knife of text editors" <bug-gnu-emacs.gnu.org>
List-Unsubscribe: <http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/pipermail/bug-gnu-emacs>
List-Post: <mailto:bug-gnu-emacs@gnu.org>
List-Help: <mailto:bug-gnu-emacs-request@gnu.org?subject=help>
List-Subscribe: <http://lists.gnu.org/mailman/listinfo/bug-gnu-emacs>,
	<mailto:bug-gnu-emacs-request@gnu.org?subject=subscribe>
Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org
Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org
Xref: news.gmane.org gmane.emacs.bugs:34635
Archived-At: <http://permalink.gmane.org/gmane.emacs.bugs/34635>

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.