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

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

bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt


From: Stefan Monnier
Subject: bug#25929: 25.2; map-delete doesn't delete permanently 1st alist elt
Date: Thu, 02 Mar 2017 10:12:09 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux)

>     (macroexp-let2 nil key
>       `(progn
>          (map--dispatch ,map
>            :list (setf (alist-get ,key ,map nil t) nil)
>            :hash-table (remhash ,key ,map)
>            :array (and (>= ,key 0)
>                        (<= ,key (seq-length ,map))
>                        (aset ,map ,key nil)))
>          ,map)))

Note that this will make it pretty much impossible to use
cl-generic dispatch.

A better option might be to provide a map-remove which works
functionally (i.e. doesn't modify its argument by side-effects), and
then change map-delete to signal an error when we ask to delete the
first element of the list (and to stop returning the "new map" since it
just works imperatively instead).


        Stefan





reply via email to

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