From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: 70524@debbugs.gnu.org
Cc: okamsn@protonmail.com, Stefan Monnier <monnier@iro.umontreal.ca>
Subject: bug#70524: [PATCH] Fix `map-elt` with `setf` for subplaces
Date: Wed, 24 Apr 2024 08:06:11 +0200 [thread overview]
Message-ID: <87a5lji9bg.fsf@web.de> (raw)
In-Reply-To: <cec20603-30c3-4db6-a96b-9d8b60e80f1c@protonmail.com> (Okamsn via's message of "Tue, 23 Apr 2024 02:10:42 +0000")
Hello Okamsn,
let's CC Stefan. Nice to see you are working on this stuff.
> Hello,
>
> Currently, the use
>
> (let ((arr (vector 0 1 2 3 4 5 6)))
> (setf (map-elt (cl-subseq arr 3) 0)
> 27)
> arr)
>
> expands to [...]
But... I must admit I'm not really convinced that this has to be
changed.
First, it is not crystal clear what the semantics should be in this
case, because `cl-subseq' as a function creates a new sequence. But
it's also a gv so it's debatable, ok.
But second - doesn't your patch lead to very inefficient code in this
example, where nearly all elements of the original sequence get replaced
by themselves in a loop (through the setter of `cl-subseq')?
Maybe there are other examples. But cases where the first argument
given to `map-elt' returns a part of the original structure (like e.g. a
`car' call) work (and there the semantics is also clearer).
So I wonder if this change is really an improvement.
But if we install it,
---
lisp/emacs-lisp/map.el | 6 +++++-
test/lisp/emacs-lisp/map-tests.el | 5 +++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/lisp/emacs-lisp/map.el b/lisp/emacs-lisp/map.el
index d3d71a36ee4..facfdd8de7b 100644
--- a/lisp/emacs-lisp/map.el
+++ b/lisp/emacs-lisp/map.el
@@ -167,7 +167,11 @@ map-elt
`(condition-case nil
;; Silence warnings about the hidden 4th arg.
(with-no-warnings
- (map-put! ,mgetter ,key ,v ,testfn))
+ ,(macroexp-let2 nil m mgetter
+ `(progn
+ (map-put! ,m ,key ,v ,testfn)
+ ,(funcall msetter m)
+ ,v)))
(map-not-inplace
I guess you should move the `with-no-warnings' wrapper along with the
comment to the inside, around the `map-put!' it is intended for.
Michael.
next prev parent reply other threads:[~2024-04-24 6:06 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-23 2:10 bug#70524: [PATCH] Fix `map-elt` with `setf` for subplaces Okamsn via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-24 6:06 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-04-24 20:14 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-25 1:59 ` okamsn--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-25 12:49 ` Augusto Stoffel
2024-04-26 12:19 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 1:08 ` okamsn--- via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-29 1:54 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-30 16:17 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-25 12:03 ` Augusto Stoffel
2024-04-25 12:42 ` Augusto Stoffel
2024-05-06 14:02 ` Michael Heerdegen via Bug reports for GNU Emacs, the Swiss army knife of text editors
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87a5lji9bg.fsf@web.de \
--to=bug-gnu-emacs@gnu.org \
--cc=70524@debbugs.gnu.org \
--cc=michael_heerdegen@web.de \
--cc=monnier@iro.umontreal.ca \
--cc=okamsn@protonmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.