From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: Negative nth index Date: Wed, 25 Dec 2024 11:30:20 +0100 Message-ID: <350E9109-04F6-4C20-B0F6-37C0A482DAD3@gmail.com> References: <865xnc6u9n.fsf@gnu.org> <87jzbs9jlk.fsf@gnu.org> <87r05wahsi.fsf@protonmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28855"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Stefan Monnier , Stefan Kangas , Tassilo Horn , Eli Zaretskii , Anand Tamariya , emacs-devel@gnu.org To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Dec 25 11:31:30 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 1tQOfq-0007N1-F9 for ged-emacs-devel@m.gmane-mx.org; Wed, 25 Dec 2024 11:31:30 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQOet-0006c4-5L; Wed, 25 Dec 2024 05:30:31 -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 1tQOeq-0006bd-Qx for emacs-devel@gnu.org; Wed, 25 Dec 2024 05:30:29 -0500 Original-Received: from mail-lf1-x130.google.com ([2a00:1450:4864:20::130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQOeo-0001mI-5D; Wed, 25 Dec 2024 05:30:28 -0500 Original-Received: by mail-lf1-x130.google.com with SMTP id 2adb3069b0e04-5401b7f7141so5164288e87.1; Wed, 25 Dec 2024 02:30:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735122623; x=1735727423; darn=gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=mZr9N7Rxat9Y2K80j534a674TCWyxewa/KKT3YwjAoY=; b=Rb/nKFRWWR6gz5xzBjzyuBQmDDyWkVF0qePUAtJ9ZzZH6B9GMbGd1vI1cVNW7wyg1S UKy9PwHTV5RQsh8T4nstpluIG0NjUpdHRq/Uae5LKYE28INRx9ID1reDz2iDV6zT2ARp m+9xjKh029rBsM069XSU8HMsu9IPbjRmxW/EnyZEgpuCq3satr+wcy9fFPb4WPsj5v/H 5hcS7ahbotQ5hdq+1OoPlq4of0AXcP9qLasJWbzla60qCqOxEm1Me18CRLRdGwaK8zEf gclZbE5hMPV0DurOKKqLhORz8wWYzHS3M4pO0H7DP2UxuaAcupFVVFfKD0PQvHOtldhs nVZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735122623; x=1735727423; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=mZr9N7Rxat9Y2K80j534a674TCWyxewa/KKT3YwjAoY=; b=uhSNjk2YeYb2KqB1l2z0PL+LFVtGE5/+NKDAfS+yuxGOUcVQQdaUFUVFaZfD3IiatN bjLT4B66IapEnbrAYNANzHbxkNpdQPPGrSBVzJAG0SktWFipn4nUvzHk9Hj5imsFEAKs IFcxtayK3OXmq8Jp+q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512:3d22:b0:541:3175:9775 with SMTP id 2adb3069b0e04-54229533622mr6378529e87.22.1735122622673; Wed, 25 Dec 2024 02:30:22 -0800 (PST) Original-Received: from smtpclient.apple (c188-150-183-180.bredband.tele2.se. [188.150.183.180]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-542238217a4sm1797515e87.191.2024.12.25.02.30.21 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Dec 2024 02:30:22 -0800 (PST) In-Reply-To: <87r05wahsi.fsf@protonmail.com> X-Mailer: Apple Mail (2.3654.120.0.1.15) Received-SPF: pass client-ip=2a00:1450:4864:20::130; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x130.google.com 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:327065 Archived-At: 24 dec. 2024 kl. 22.33 skrev Pip Cet via Emacs development discussions. = : > 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)). >> 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? >=20 > 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. And there's not much performance to gain from it: while a good compiler = might use it for value range propagation, as in (use (nth n lis)) (if (< n 0) ...) ; dead if nth signals on negative n it doesn't really justify a change.