GNU bug report logs -
#70524
[PATCH] Fix `map-elt` with `setf` for subplaces
Previous Next
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
Message #26 received at 70524 <at> debbugs.gnu.org (full text, mbox):
On Thu, 25 Apr 2024 at 14:03, Augusto Stoffel wrote:
> On Tue, 23 Apr 2024 at 02:10, Okamsn via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote:
>
>> 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)
>
> Since map-put! may raise a not-in-place signal, and I doubt the macro
> expansion checks for whatever condition it is that leads to that, I
> would say this use-case is essentially broken.
Sorry, just ignore that :-).
What I actually wanted to say is that IMO there's a general conceptual
problem to consider map-like values as places. There's no reasonable
way (cl-subseq arr 3) can be seen as a place AFAICT.
But even in a language like Python (where map-like things can be seen as
places, since there are no liked lists to ruin the party), I don't
understand what the above code is supposed to do. This code
arr = [0, 1, 2, 3, 4, 5, 6]
arr[3:][0] = 27
arr
will just copy a portion of arr as new list, mutate its first element,
then throw array that copy.
This bug report was last modified 1 year and 16 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.