From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Michael Heerdegen via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#68863: Add support for using setf with seq-subseq Date: Wed, 08 May 2024 23:01:22 +0200 Message-ID: <87msp0f271.fsf@web.de> References: <050ba625-2372-425f-85c6-988e2ef4cf14@protonmail.com> <86y1bvw5ff.fsf@gnu.org> <2dfd9d7f-5c63-4e1d-845c-cd245a71fc34@protonmail.com> <8d2a8d06-5b69-4587-9aab-36f7c792c623@protonmail.com> <1fca0de5-236e-428f-9224-b03a4d7d6998@protonmail.com> <5db43ef0-f218-4790-b263-a3eb80929d9b@protonmail.com> Reply-To: Michael Heerdegen Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10078"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 68863@debbugs.gnu.org, Eli Zaretskii , Nicolas Petton , Stefan Monnier To: Okamsn Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 08 23:01:59 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 1s4oQI-0002Yi-Rb for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 08 May 2024 23:01:58 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s4oPz-0006jt-Hu; Wed, 08 May 2024 17:01:39 -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 1s4oPx-0006jd-Ug for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 17:01:37 -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 1s4oPx-0000Lp-Lp for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 17:01:37 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1s4oQM-0003Bf-37 for bug-gnu-emacs@gnu.org; Wed, 08 May 2024 17:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Michael Heerdegen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 08 May 2024 21:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68863 X-GNU-PR-Package: emacs Original-Received: via spool by 68863-submit@debbugs.gnu.org id=B68863.171520208312236 (code B ref 68863); Wed, 08 May 2024 21:02:02 +0000 Original-Received: (at 68863) by debbugs.gnu.org; 8 May 2024 21:01:23 +0000 Original-Received: from localhost ([127.0.0.1]:50868 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4oPj-0003BI-D7 for submit@debbugs.gnu.org; Wed, 08 May 2024 17:01:23 -0400 Original-Received: from mout.web.de ([212.227.15.3]:43793) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1s4oPf-0003B3-8b for 68863@debbugs.gnu.org; Wed, 08 May 2024 17:01:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=web.de; s=s29768273; t=1715202039; x=1715806839; i=michael_heerdegen@web.de; bh=rwMxKDeDStOzzYQ/Cqzdv+Y5q+OadjD02S61O2ZvoVw=; h=X-UI-Sender-Class:From:To:Cc:Subject:In-Reply-To:References:Date: Message-ID:MIME-Version:Content-Type:cc:content-transfer-encoding: content-type:date:from:message-id:mime-version:reply-to:subject: to; b=G6KKo+tNeuldsqKa/S0/umDwbEU70X7x0rI2i5Fq4OslcYtF6R+RGFsKmmj8AvjJ UmuyK88zoXMVZNPR9gFSlsntKGznwbC8iZ0+sevIKsjYq1mvYZPyKRM1cIXxH2eMf 4v10zmJJDczZvtiOYS/RGEyxYMlPszHuEfudpGucLD4OEAQzvLdGABkS40qzbmZ29 35YS4WOrBulDxbyx36AKzL6bWDaFPmGAnubgvQkGa/EioJVj2zQqyXjMCQlMdpGKY 9w9ORwlM+06cRycSDjgeuLpoNrWBBXMT2HiKBPJWhfsLZ+PSUtdC82AOOyzNauq/j coJbYXTWehfL/G47JA== X-UI-Sender-Class: 814a7b36-bfc1-4dae-8640-3722d8ec6cd6 Original-Received: from drachen.dragon ([84.57.248.23]) by smtp.web.de (mrweb006 [213.165.67.108]) with ESMTPSA (Nemesis) id 1N8Epo-1siBWx2rg0-0146EW; Wed, 08 May 2024 23:00:39 +0200 In-Reply-To: <5db43ef0-f218-4790-b263-a3eb80929d9b@protonmail.com> (okamsn@protonmail.com's message of "Tue, 07 May 2024 01:45:44 +0000") X-Provags-ID: V03:K1:L9l9xCr2g7olPLO31zMmHSTWIn0LpJNGSPe7imAbRBeXjYHc1Y/ CYeU++YbfIBKO5l4UCtHMD1La0oqI3HxwPLFoR2a0nMTLd/W7tKVHGF1qhXMVqXUXLvljbO JDA9jNcBg2LNOwXrgTXP0h9ABY7UK3PLkYbAmOuo5SVi/W5WkIUnUJEaQFilIHWr6y7JrRF W+40BlRXxlLdJYEjQGhTg== UI-OutboundReport: notjunk:1;M01:P0:U0CcDwkOcso=;aujmz+EXYhpBBw4n3272e5j9ZFF 0Ad+v3PJOINgIa83wX+Ki9JvIUt9tg2gQT5D60fJVr4SCOR17UghkKPN9W6I30DGAJyUvat0K bukObyHZWGBg0C3HJFTaaUdDTYN49ri+Z1lOnlC2q50JQHolpJKK7WFhpzdmgeJSlBTIYYvt0 3n3/I2DTqyP/uaHT7PenBnHbDGeP4BUpmF/5hZsKLhkDjeK5DWo1o974UjNdPVrzb61j4RF82 85CVeBhFpofC0M/lZm2D3asiJMnZ3WFV0YtdI+araw8YdcQPLfs1Wu8/QqZhKPkVx9GEfAnjR MbnXpis2GU95d7qFQgLhk/QoYe5dKbh/niqHlpXT3lsxmUjTsBUvr8aOlNw4RYvr5dyx5ci1F xVm9DjxPKO1h4RrXnA1PaiKeXcKMr5gt0OekRSG1OddJZEQ4t9m5g2ZjX3RSeYS7/NHbgiwHp XJD90cmQ7eCaOKTExGn5eurETdINKoxXZk+uz/9w+vhXH+fyjcEDLHQ8zxLbxcA6E6NcgFqB6 GBIBHR5r/L3DX9NwzDsYyOqiXlG2H7KTQBemqx4vgitI6VxjdAlLhpXJ0rZ28itanhwn2I+kE pk38VokBxKajkf8CjoNGtksDjcAjo9aetfFjfrN49Nk+YL0wQVq1UkmBq9j8EcOYefP3Ho7HD L4fdT2mcRskWMdzy0eGenVIkAAtUdYWkHRF9En9rJ7JtG4mxOwIwylv/YjQCur/G+B6zEjp4Y mXCM6PnDfMKpsQfzvT3JgpszWy7TcHmvryZOFlc/HF9hLf4SebFkQ1PrW5GyG+kxynLpxvz9 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:284696 Archived-At: Okamsn writes: > Subject: [PATCH v2] Add setf support for seq-subseq. Thank you for the update. I wonder about the implementation for listp STOREs: > +(cl-defmethod (setf seq-subseq) (store (sequence list) start &optional end) > + "Modify the elements of SEQUENCE from START to END to be those of STORE. > +END is exclusive. > + > +If END is omitted, it defaults to the length of the sequence. If > +START or END is negative, it counts from the end. [...] In the case where we don't count from the end: > +error if START or END are outside of the sequence (i.e too large > +if positive or too small if negative). > + > +SEQUENCE is neither lengthened nor shortened." > + (let* ((len (seq-length sequence)) running through the complete list just to get its length which we don't need is a waste of time - right? > + (catch tag > + (seq-do (let ((replaced (nthcdr idx sequence))) > + (lambda (v) > + (if (< idx idx-end) > + (setf (car replaced) v > + replaced (cdr replaced) > + idx (1+ idx)) > + (throw tag nil)))) > + store)))) > + store) And wouldn't it here be more efficient to use `setcar' and `setcdr' manipulations to insert the complete sequence (if it's a list, else we may convert it into one) in one go instead of replacing elements one by one? Thanks, Michael.