From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#70524: [PATCH] Fix `map-elt` with `setf` for subplaces Date: Wed, 24 Apr 2024 16:14:51 -0400 Message-ID: References: <87a5lji9bg.fsf@web.de> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35797"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: okamsn@protonmail.com, 70524@debbugs.gnu.org To: Michael Heerdegen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed Apr 24 22:19:07 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rzj58-00098Y-EQ for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 24 Apr 2024 22:19:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rzj4p-0003Fw-11; Wed, 24 Apr 2024 16:18:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rzj4o-0003Fc-Bl for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2024 16:18:46 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rzj4o-0003Vd-34 for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2024 16:18:46 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rzj55-0004DE-6z for bug-gnu-emacs@gnu.org; Wed, 24 Apr 2024 16:19:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 24 Apr 2024 20:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70524 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70524-submit@debbugs.gnu.org id=B70524.171398990015733 (code B ref 70524); Wed, 24 Apr 2024 20:19:02 +0000 Original-Received: (at 70524) by debbugs.gnu.org; 24 Apr 2024 20:18:20 +0000 Original-Received: from localhost ([127.0.0.1]:60143 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzj4O-00045h-AS for submit@debbugs.gnu.org; Wed, 24 Apr 2024 16:18:20 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:15274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rzj4I-00043m-LE for 70524@debbugs.gnu.org; Wed, 24 Apr 2024 16:18:18 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 011FF442879; Wed, 24 Apr 2024 16:17:51 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1713989865; bh=l1hjl9lCHjAxQyuomi/XiqBRi+DU6AiNf8hO56xVlFQ=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=LhhxmzXMJ9NE/gMsZNdDPy8DpHrrx1WGmJFVDJg7eBzSZsFUhIsDovMbELVYc0UJV EYgNnt2BZqUfOVB7yAPHZur9ZVTVZrdSOTJ7fKTmOn2xWZPTyv4/SixGWsVUN8rO5/ cW1Ov3KZrJyAKHqnoVRdgVbgx0YDGcHyENVziUhcC0SOA2CxCfkc769dA1fMeHy/Qg 0S2QuDwNK8IaCYhwkqVlNAlM5Be7L0T+tCArki1/gjpC7UnpOus6EdujsQ+VjIasb7 MePVOdxRvlvpOM9studBaPbd28Xx1ylpmvVgxRy6dk1ZOlPMPa0h6VuCnHMhtdHNtJ y1TRwFBA9TWRQ== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5F63744287E; Wed, 24 Apr 2024 16:17:45 -0400 (EDT) Original-Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4FAA5120287; Wed, 24 Apr 2024 16:17:45 -0400 (EDT) In-Reply-To: <87a5lji9bg.fsf@web.de> (Michael Heerdegen's message of "Wed, 24 Apr 2024 08:06:11 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283930 Archived-At: >> 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. I'm also unconvinced. AFAICT the same problem occurs with (setf (aref (cl-subseq arr 3) 0) 27) and I can't think of a good reason why `map-elt` should behave differently. Furthermore, the change would also fundamentally change the way `map-elt` can be used as a gv-place, in the sense that (setf (map-elt (funcall foo bar) 0) 27) would signal an error during macroexpansion because (funcall foo bar) is not a valid gv-place. > 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')? Yes, that's another issue. I think if we want to support such `setf` in a way that is good enough to that we can recommend its use, we'd need to turn it into something that behaves more or less like: (map-set! arr (+ 3 0) 27) But I must admit that I don't know how to get there. Stefan