[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23105: 25.0.92; map-put does not change its argument MAP
From: |
Nicolas Petton |
Subject: |
bug#23105: 25.0.92; map-put does not change its argument MAP |
Date: |
Fri, 25 Mar 2016 16:14:43 +0100 |
User-agent: |
Notmuch/0.21 (http://notmuchmail.org) Emacs/25.1.50.1 (x86_64-unknown-linux-gnu) |
Sho Takemori <stakemorii@gmail.com> writes:
> Thanks for the fix. But after the fix, if MAP is a list literal, then it
> raises an error.
> For example, this raises an error.
> (map-put '((a . 1)) 'a "value")
>
> This works.
> (map-put [0 1 2] 1 "value")
>
> It is an expected error?
Yes, in the sense that the same error will be raised if you try to do it
with a setf on an alist:
(setf (alist-get 'b '((a . 1))) 3) ;; => invalid-function (a . 1)
(let ((alist '((a . 1))))
(setf (alist-get 'b alist) 3)) ;; => works fine
Note however that mutating literal lists is in general not a good idea,
as conses might be shared.
Nico
signature.asc
Description: PGP signature