|
From: | Michael Heerdegen |
Subject: | Re: emacs-25 2460cfa: * doc/lispref/lists.texi (Association Lists): Document 'alist-get'. |
Date: | Tue, 19 Jan 2016 20:25:47 +0100 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
John Wiegley <address@hidden> writes: > The old way: > > GET: (cdr (assq key my-alist)) > SET: (setcdr (assq key my-alist) new-value) > > The new hotness: > > GET: (alist-get key my-alist) > SET: (setf (alist-get key my-alist) new-value) That's only one half of the truth: Your two SETs are different if KEY is not yet present in MY-ALIST. "The old way" doesn't work in that case, the new one does. It replaces a complete (if (assq ...) (setcdr ... ...) (push ... ...)) Michael.
[Prev in Thread] | Current Thread | [Next in Thread] |