GNU bug report logs - #34708
alist-get has unclear documentation

Previous Next

Package: emacs;

Reported by: "Miguel V. S. Frasson" <mvsfrasson <at> gmail.com>

Date: Sat, 2 Mar 2019 04:52:01 UTC

Severity: minor

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

Bug is archived. No further changes may be made.

Full log


Message #44 received at 34708 <at> debbugs.gnu.org (full text, mbox):

From: Eric Abrahamsen <eric <at> ericabrahamsen.net>
To: Drew Adams <drew.adams <at> oracle.com>
Cc: Michael Heerdegen <michael_heerdegen <at> web.de>, 34708 <at> debbugs.gnu.org,
 "Miguel V. S. Frasson" <mvsfrasson <at> gmail.com>
Subject: Re: bug#34708: alist-get has unclear documentation
Date: Mon, 04 Mar 2019 08:24:14 -0800
On 03/03/19 07:51 AM, Drew Adams wrote:

[...]

> It's important to not give the impression that
> there must be an _existing_ element with KEY.
> Showing an example can help dispel that mistake.
>
> (setq foo ())
> (setf (alist-get 'a foo) 1
> (alist-get 'b foo) 2)
>
> C-h v foo; ==> ((b. 2) (a. 1))

I think it would be nice to have an example that shows both a common
use-case (as an accumulator), and how to use REMOVE. I started off with
the accumulator part:

(let (word word-freq)
  (while (setq word (pop word-list))
    (cl-incf (alist-get word word-freq 0 #'equal) 1)))

But so far haven't come up with a non-contrived way to work REMOVE in
there...




This bug report was last modified 6 years and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.