From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.devel Subject: Re: Negative nth index Date: Wed, 25 Dec 2024 14:18:07 +0000 Message-ID: References: <865xnc6u9n.fsf@gnu.org> <87jzbs9jlk.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10344"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 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 Wed Dec 25 15:18:31 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 1tQSDX-0002TJ-5z for ged-emacs-devel@m.gmane-mx.org; Wed, 25 Dec 2024 15:18:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQSDF-0001jG-6y; Wed, 25 Dec 2024 09:18:13 -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 1tQSDD-0001j4-RZ for emacs-devel@gnu.org; Wed, 25 Dec 2024 09:18:11 -0500 Original-Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tQSDC-0006Qu-BJ; Wed, 25 Dec 2024 09:18:11 -0500 Original-Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-5d3d479b1e6so7795009a12.2; Wed, 25 Dec 2024 06:18:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735136288; x=1735741088; darn=gnu.org; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:from:to:cc:subject:date:message-id:reply-to; bh=55515pcJca75KEzGjZE4feksJB56oO4IhAi5GnQhMpA=; b=DvaIkepAbWABBzayNXBW8rDcpZXSqm/9Noda6DnMv9AE2XD3t2jw3zoeE3ke84zfi7 juEyjdLW2kt2WJfjYI0Wj6GT3oZjzhf3cwKrNUPJ3IvzgMaerDsGi8bTYk+MEM5qUiyv app6ATMbyHgNI34Az7beoaWkCWaBPAu+aDxeReCzag/LSz+wNXgYKRApI9g5JUuE0PmP prmEidQt+fSHJnz3X4ccLMxxHSBbDccupUgkBRhqUZbqnb8LMr6UQaXhFrZmf6h+ZJCb WWM6nVWQvt9k/D/SBQaKXIsb9+T1IX572yNoMffRipwNno2IacEBzCrmT4uFnzvOxfCw HaYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735136288; x=1735741088; h=cc:to:subject:message-id:date:mime-version:references:in-reply-to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=55515pcJca75KEzGjZE4feksJB56oO4IhAi5GnQhMpA=; b=V8ITgDkd/mj5tIUUIIQQTPOVnKrRvnA+A9CCc3dV/21wzsbXVTtqObtwAe0V2L5r+l EpyLds3Sx+D0M4bzjB9uDy5f6w1mervPXIVW2tFcZfNAZcRzj5jgfEAj89nv1ODK+t+M XYn5qfcmsKlrbKdvJ7qvEW5Z3ksimm2cfpD/bHUEfQUrLEcAEjOpAiySje830ySHimGV dcyPdvFjaQ3hhfn/szN5JquEUkN7UeDArRHDSWH+DghH6EY76bQ0nRlXmlrxsr6shd5h x2Wc9uEWicQq5Xbt33sndd/qYdX78cmwxl2mB2zHr3cIpcsAMl7er68Nzvb5+VWYPUMC DUTw== X-Forwarded-Encrypted: i=1; AJvYcCUIAFa1i5zR/XelsWiJJlPlnsRJTQA9vUog7d3jzT3dhPYk6LLsV5pJZJhkzJIw5Nbr8iJi@gnu.org, AJvYcCWFCjiQ3FDeDms4I1fVq/v4YyWCvDgPA4x6xr9T9WASbfOydt/bTYuR4QAX98UVDTqd+Y6t40+utpkgjrg=@gnu.org X-Gm-Message-State: AOJu0YyWLFf4i7MxbU5vyxgJvuC6Mtkua0mOXPViweqMPQzgg+3mAQUK vd8cMc/oE+n5Dc0Di1oAoHxAbEA4UEjRd7q8mZ4yHmaSt3oGxiuPoARIys1jke8/PxV/fO0CLsX ufYRmMOoXNMnY1O1ZwDoIHJrELPQ= X-Gm-Gg: ASbGncvQGor5aTuMo3zWY0GTZf3KIlSd4A/OJE/dLKfvCsvfrMvjEbaYalXS463aDI+ OvD5EGCoMti4f7eaNuft5aL232Zvw/TcLYrEQDl3Z X-Google-Smtp-Source: AGHT+IHZts/pQq5fcPHjzdxzAxryofn/MEb1kLH61Zdx9KgBG+xxpcyc7yANSB4Zjxkbxtplc2GQWvKCqVKXq4wxB+I= X-Received: by 2002:a05:6402:3206:b0:5d1:2377:5af3 with SMTP id 4fb4d7f45d1cf-5d81dd83b23mr46384847a12.5.1735136287547; Wed, 25 Dec 2024 06:18:07 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Wed, 25 Dec 2024 14:18:07 +0000 In-Reply-To: Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=stefankangas@gmail.com; helo=mail-ed1-x52e.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:327097 Archived-At: Stefan Monnier writes: >>> 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. >> Stefan Monnier, any comments here? > > I don't see a strong argument in favor of making it index from the end > rather than signal an error. I'd make it signal an error like in CL, Clojure, and Scheme, but it doesn't do that today, so the change would not be backwards-compatible. So I'm not sure what to do here or how. For reference, the current behavior is this: (nth -1 '(1 2 3)) => 1 (nth -2 '(1 2 3)) => 1 (nth -3 '(1 2 3)) => 1 (nth most-negative-fixnum '(1 2 3)) => 1