GNU bug report logs - #70524
[PATCH] Fix `map-elt` with `setf` for subplaces

Previous Next

Package: emacs;

Reported by: Okamsn <okamsn <at> protonmail.com>

Date: Tue, 23 Apr 2024 02:12:03 UTC

Severity: normal

Tags: patch

Done: Michael Heerdegen <michael_heerdegen <at> web.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#70524: closed ([PATCH] Fix `map-elt` with `setf` for subplaces)
Date: Mon, 06 May 2024 14:02:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Mon, 06 May 2024 16:02:01 +0200
with message-id <87le4nght2.fsf <at> web.de>
and subject line Re: bug#70524: [PATCH] Fix `map-elt` with `setf` for subplaces
has caused the debbugs.gnu.org bug report #70524,
regarding [PATCH] Fix `map-elt` with `setf` for subplaces
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
70524: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=70524
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Okamsn <okamsn <at> protonmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Fix `map-elt` with `setf` for subplaces
Date: Tue, 23 Apr 2024 02:10:42 +0000
[Message part 3 (text/plain, inline)]
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

     (let ((arr (vector 0 1 2 3 4 5 6)))
       (let* ((v arr))
         (condition-case nil
             (with-no-warnings
               (map-put! (cl-subseq v 3) 0 27 nil))
           (map-not-inplace
            (let* ((new (map-insert (cl-subseq v 3) 0 27)))
              (progn
                (cl-replace v new :start1 3 :end1 nil)
                new))
            27)))
       arr)

which does not modify the original variable `arr` due to how `map-put!` 
is being used. With the attached patch, it would expand to

     (let ((arr (vector 0 1 2 3 4 5 6)))
       (let* ((v arr))
         (condition-case nil
             (with-no-warnings
               (let* ((m (cl-subseq v 3)))
                 (progn
                   (map-put! m 0 27 nil)
                   (let* ((new m))
                     (progn
                       (cl-replace v new :start1 3 :end1 nil)
                       new))
                   27)))
           (map-not-inplace
            (let* ((new (map-insert (cl-subseq v 3) 0 27)))
              (progn
                (cl-replace v new :start1 3 :end1 nil)
                new))
            27)))
       arr)

which correctly sets the value using `cl-replace` as the setter for 
`cl-subseq`.

Thank you.
[0001-Make-setf-with-map-elt-work-with-subplaces.patch (text/x-patch, attachment)]
[Message part 5 (message/rfc822, inline)]
From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: 70524-done <at> debbugs.gnu.org
Subject: Re: bug#70524: [PATCH] Fix `map-elt` with `setf` for subplaces
Date: Mon, 06 May 2024 16:02:01 +0200
Hello,

It seems the discussion has come to an end, and we have not decided to
do anything, so I'm closing this report for now.

Feel free to reopen when there is something new, or to continue
discussing other aspects in this or other/new bug reports.


Thank you,

Michael.


This bug report was last modified 1 year and 51 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.