bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#34708: alist-get has unclear documentation


From: Michael Heerdegen
Subject: bug#34708: alist-get has unclear documentation
Date: Tue, 12 Mar 2019 14:12:31 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Drew Adams <drew.adams@oracle.com> writes:

> > (progn
> >   (setq my-alist '((a . 1) (b . 2)))
> >   (push (car my-alist) my-alist)
> >   ;; my-alist ==> (#1=(a . 1) #1# (b . 2))
> >   (setf (alist-get 'a my-alist nil 'remove) nil))
> >   ;; my-alist ==> ((b . 2))
> >
> > This is because the code uses delq to delete a found cons, and delq
> > removes all `eq' elements.
> >
> > Is it worth to document or change that?
>
> Sounds like an implementation/design artifact.  If that will stay as
> part of the design then yes, I'd say such behavior needs to be
> documented.

BTW with a different viewpoint, when you use

 (setcdr (assoc 'a my-alist) 17)

on the above degenerated alist you also change _both_ of the 'a
associations, so one could argue that the `alist-get' setter behaves
correctly when removing both: there are not two 'a associations in
MY-ALIST but the same one has just been added two times, so it's correct
to remove both of them.

Michael.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]