Subject: bug#75170: add-to-alist: new function

From: Roland Winkler <[email-masked]>
Date: Mon, 20 Jan 2025 13:08:55 -0600

On Mon, Jan 20 2025, Michael Heerdegen wrote:
> Please do not limit your considerations to this special case.  DEFAULT
> and the second arg of setf are different things.  The expression you
> setf to is not necessarily a constant:
>
>   (setf (alist-get ...) (get-the-element)).
>
>
> About your second question: Please also think about the general case.
>
> The promise of (setf PLACE VAL) is that VAL will be stored in PLACE
> after the operation.  The REMOVE arg just means: it is allowed to
> achieve that by removing an association when appropriate.
>
> (alist-get ... DEFAULT ...) will return DEFAULT
> when an element is not present.  If we setf to a different value we
> can't remove anything from the alist because our promise would not hold
> and it would not be appropriate.

Sure. - I just do not know real-world examples where this combination of
things is an efficient way to go.