From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?iso-8859-1?Q?Sebasti=E1n_Mon=EDa?= Newsgroups: gmane.emacs.devel Subject: Re: Negative nth index Date: Tue, 24 Dec 2024 10:24:55 -0500 Message-ID: References: <865xnc6u9n.fsf@gnu.org> <87jzbs9jlk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31441"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Stefan Kangas , Tassilo Horn , Eli Zaretskii , Anand Tamariya , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 24 16:25:36 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 1tQ6ms-0007uu-DH for ged-emacs-devel@m.gmane-mx.org; Tue, 24 Dec 2024 16:25:35 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQ6mR-0002qA-VR; Tue, 24 Dec 2024 10:25:08 -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 1tQ6mO-0002nd-45 for emacs-devel@gnu.org; Tue, 24 Dec 2024 10:25:04 -0500 Original-Received: from fhigh-b4-smtp.messagingengine.com ([202.12.124.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQ6mM-0004lc-1Y; Tue, 24 Dec 2024 10:25:03 -0500 Original-Received: from phl-compute-02.internal (phl-compute-02.phl.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id BBFF22540102; Tue, 24 Dec 2024 10:24:57 -0500 (EST) Original-Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-02.internal (MEProxy); Tue, 24 Dec 2024 10:24:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sebasmonia.com; h=cc:cc:content-transfer-encoding:content-type:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=fm3; t=1735053897; x=1735140297; bh=f7bqSAiM/r5kTazQVbwh3XJbYwBeoNm7 yyTZUA4Q2fI=; b=cNmuXcF0/U+FaKX7Y1kGfbLwlVYt9my/Pp9QwneFey5Mqgcc VZROa+GMA6Hip+yCvexVWD7mtIvGVOrdgC5GeFLre5/qk9XliI/9uxk/KPiUH8DQ iEPKWwDJMPIk7RzRoAepdRcd1V7qO9vi5+sG72sGlejMU1REyhYBEzkLYLH+jS4S JILf7NpsEZ74eE3JSTS2BHdwEHCAHIi8LGBdZBIXpUouZx6aGXH430CBMZ72Nz9A +UHChznydicdHBL0tIGjg+QOtKGr1W+Xy0Dp3wBlUoBHa48YzHmOpNDCDIPvQiQf gVGraVuPYpiIeJ9QYupC/5pRvGl3dSFSHe2XRQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1735053897; x= 1735140297; bh=f7bqSAiM/r5kTazQVbwh3XJbYwBeoNm7yyTZUA4Q2fI=; b=c L+J2i2W4sDM2vp2On8H9QwANofj4yhWZft9ofr1ckavlNEw0XG4TZzRRK99L0Kf+ 2OxM2CJSgqhuFf9O1nyU4rzNU9r4Lu6ZW3HNUw5Fx7dPMsYN4Cl6YYNTDeOH4gve 4/Pdb3xMFScyj87bjUVoUvaSH8uUV/CUWDDjc+m9GJwJbBSz0ik8O7O/7h0VKBAe UpmluGJmrjjRmTgJi1xGzhkABrf2jMRh2b/pEFXZGyj6KTLP0vELbIfqTcq2+Qll bpocnzHUcqbPLUpiyxrzOKpPuh+eTSRCF4lHCgJ2Qq0TX6rz6f2Fj92V4Si68qaW DWT5zyl06En0KiVIP6hcA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddugedgjeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh htshculddquddttddmnecujfgurhephffvvefujghffffkfgggtgfgsehtqhertddtredu necuhfhrohhmpefuvggsrghsthhijohnucfoohhnvogruceoshgvsggrshhtihgrnhessh gvsggrshhmohhnihgrrdgtohhmqeenucggtffrrghtthgvrhhnpeejfeekteevuedvffeh tdegueektdevkeevtefhvdfgffeiieeiteeugfdvieevkeenucffohhmrghinhepshgvsg grshhmohhnihgrrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomhepshgvsggrshhtihgrnhesshgvsggrshhmohhnihgrrdgtohhmpdhnsg gprhgtphhtthhopeeipdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegvmhgrtghs qdguvghvvghlsehgnhhurdhorhhgpdhrtghpthhtoheprghtrghmrghrihihrgesghhmrg hilhdrtghomhdprhgtphhtthhopegvlhhiiiesghhnuhdrohhrghdprhgtphhtthhopeht shguhhesghhnuhdroh X-ME-Proxy: Feedback-ID: iab2c46da:Fastmail Original-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 24 Dec 2024 10:24:57 -0500 (EST) In-Reply-To: (Stefan Monnier's message of "Tue, 24 Dec 2024 00:11:26 -0500") Received-SPF: pass client-ip=202.12.124.155; envelope-from=sebastian@sebasmonia.com; helo=fhigh-b4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, 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-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:327024 Archived-At: Hello, Stefan Monnier writes: >>>>> Should negative index for nth be valid? e.g. >>>>> (nth -1 '(1 2)) returns 1 > > [ I'd make it return 2 otherwise you can't use it to return the > last element. ] > >>>> What does this do in other Lisps? >>> In CL, it errors (ditto for nthcdr with negative index). Same for (nth >>> '(1 2 3) -1) in Clojure or (list-ref '(1 2 3) -1) in Scheme. And for this reason I _would not_ expect it to work with negative numbers in Elisp. > 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? This is "modern"? behaviour that I would expect from seq-elt, because it is the newest, bell and whistles library. I have a feeling that keeping `nth' more limited for reasons of tradition is silly, but...it feels right. Regards, Seb --=20 Sebasti=E1n Mon=EDa https://site.sebasmonia.com/