[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#50290: Using `setf` on `map-elt` repeats evaluation for returning th
From: |
Okamsn |
Subject: |
bug#50290: Using `setf` on `map-elt` repeats evaluation for returning the value of `setf` |
Date: |
Tue, 31 Aug 2021 02:58:11 +0000 |
Hello,
When I do `(setf (map-elt map key) (my-func))`, it expands to
(let* ((key key))
(condition-case nil
(with-no-warnings
(map-put! map key (my-func) nil))
(map-not-inplace
(setq map (map-insert map key (my-func)))
(my-func))))
The repetition of `(my-func)` raises warnings. Compare with using
`(setf (alist-get key map) (my-func))`, where the result of `(my-func)`
is bound to `v` so that it is only called once:
(let* ((p (if (and nil (not (eq nil 'eq)))
(assoc key map nil)
(assq key map)))
(v (my-func)))
(progn
(if p
(setcdr p v)
(setq map (cons (setq p (cons key v))
map)))
v))
This is on Emacs 28 with Map.el 3.1.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- bug#50290: Using `setf` on `map-elt` repeats evaluation for returning the value of `setf`,
Okamsn <=