From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet via "Emacs development discussions." Newsgroups: gmane.emacs.devel Subject: Re: Negative nth index Date: Wed, 25 Dec 2024 10:56:26 +0000 Message-ID: <87ed1w9glz.fsf@protonmail.com> References: <865xnc6u9n.fsf@gnu.org> <87jzbs9jlk.fsf@gnu.org> <87r05wahsi.fsf@protonmail.com> <350E9109-04F6-4C20-B0F6-37C0A482DAD3@gmail.com> Reply-To: Pip Cet Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23239"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Stefan Kangas , Tassilo Horn , Eli Zaretskii , Anand Tamariya , emacs-devel@gnu.org To: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 25 12:50:09 2024 Return-path: Envelope-to: ged-emacs-devel@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 1tQPtx-0005sr-8j for ged-emacs-devel@m.gmane-mx.org; Wed, 25 Dec 2024 12:50:09 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQPsu-0003qy-I1; Wed, 25 Dec 2024 06:49:04 -0500 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 1tQP46-00026u-If for emacs-devel@gnu.org; Wed, 25 Dec 2024 05:56:34 -0500 Original-Received: from mail-4316.protonmail.ch ([185.70.43.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQP45-0004Kf-2S; Wed, 25 Dec 2024 05:56:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1735124191; x=1735383391; bh=wD3iNpV5AHb9hvqX0823aXTl0Jzhnv0f2jJ/+MquAIE=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=xSFc82Gm4pyft3FmHgLvX3mE7WqAfkwT1uojL1D+DDQOErYkfInx5G4JbHmNDIL4S LVEF3PHsN5ubZu6FL6kOIpfpSZ/ATLmsy//l7RyJKQyPSZ5qrNp0ssbTcC5Wbd4NPs 0w7P6BP/WNlCaVpdmKhoXgkpYCY09cehS4LtXpk3looE6dzP0Q/KZjM1Gxn42ueEEq VWYPU1pHRDS6xbYx0+J6ZV6hD9KTqpaj8X1ogA4QZ3s2xw+NOnp2k56r/3iZwF/mwG pCJIvDlGuYJm9o7jiMwx0xlPiwzuQlqmjLlCJ2VRyjhMBse0XdEbqfSGGhlf8qZ+9g sxzZJm1Uvbinw== In-Reply-To: <350E9109-04F6-4C20-B0F6-37C0A482DAD3@gmail.com> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 0c9ae0e7f161911c21e94a39eedb96ee1e1502a0 Received-SPF: pass client-ip=185.70.43.16; envelope-from=pipcet@protonmail.com; helo=mail-4316.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Wed, 25 Dec 2024 06:49:01 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:327073 Archived-At: Mattias Engdeg=C3=A5rd writes: > 24 dec. 2024 kl. 22.33 skrev Pip Cet via Emacs development discussions. <= emacs-devel@gnu.org>: > >> I think the OP meant that (nth -1 '(1 2)) is 1 on current Emacs, which >> is definitely unexpected. > > It's a straight consequence of (nth N L) =3D (car (nthcdr N L)). s/nth/nthcdr/g in my email, then. Of course the two should behave analogously, the question is whether they should both throw an error (my opinion) or shouldn't. (My apologies for actually writing about nthcdr but calling it nth in the last mail). >>> I don't see a strong argument in favor of making it index from the end >>> rather than signal an error. What would the implementation look like? >> >> I agree, but the current implementation does not signal an error. It >> should, and I think that's what the suggestion was. > > It is true that signalling an error for negative arguments might catch > some bugs but doing so would also risk breaking working code that > relies on the current (well-defined) behaviour. If it were merely undocumented, I might agree, but the current behavior doesn't match the documentation, because taking cdr -1 times is obviously an impossible thing to do. > And there's not much performance to gain from it This isn't about performance. Pip