From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?B?TWF0w7rFoQ==?= Goljer Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] seq.el: add seq-last for symmetry with seq-first Date: Tue, 14 Mar 2023 20:14:03 +0100 Message-ID: <87sfe7kux0.fsf@gmail.com> References: <871qlrmr14.fsf@gmail.com> <87fsa7cq0v.fsf@posteo.net> <87wn3jl4f8.fsf@gmail.com> <875yb3cntx.fsf@posteo.net> <87r0trb2pz.fsf@gmail.com> 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="38402"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Augusto Stoffel , Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 14 20:52:39 2023 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 1pcAhK-0009pV-Vt for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Mar 2023 20:52:38 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pcAgy-0002Af-Mx; Tue, 14 Mar 2023 15:52:16 -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 1pcA66-0007RO-NT for emacs-devel@gnu.org; Tue, 14 Mar 2023 15:14:13 -0400 Original-Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pcA63-00025O-Oj for emacs-devel@gnu.org; Tue, 14 Mar 2023 15:14:09 -0400 Original-Received: by mail-ed1-x531.google.com with SMTP id y4so36858350edo.2 for ; Tue, 14 Mar 2023 12:14:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678821246; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=alIK1vFVe0yYb0owwBKQFIAeS7/fX7Jq+Ifdrhacyxc=; b=HL61P27yRwgfq7f26gVEzY5c0UIr900YGHgKqhq40n7+ePlYgaUlVV3cAQOGlJMOu+ YEwaRNgi2DggFdi706iNo4t6PqM6L70O/1DW04PnFNjv9HOy2jvEI+N3jmQTJ/tlS5Yy 8hbKQQOMo01w2kdid4B+9ikOmmiCjcCcjfBQtX//R7HYyi59JK/Ktqj8LOJaOGPLu6JR +nFL+zCsV+j+CUgCqrwL4p0U7XONpZ4It9R+rfpQ/HLsGqrZJJRSuArop1quSkA24tUy bCCD6R+Lquqt5xcziCQevbXGc7d52Ob44iE/sPnfNjbgEFUREDjJ9BNsRdwpPmfgEjH3 vfLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678821246; h=content-transfer-encoding:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=alIK1vFVe0yYb0owwBKQFIAeS7/fX7Jq+Ifdrhacyxc=; b=4pKI7yB06tPy9Mix07127BivgMEMXL9M1qZ1FgcOiNg9F4BgoImKFPWsp19V/rKriT 2p2Cm5WxtlGZWbQ+751Ixxf3vNyvkk9jgHrjIxePoCyqzsraJdTJNzGBcQ6ACSr468m+ wg6yhngd3Nr7hqUd8wNzbgrijEPcBlVXPGRI25H1VxAOj6Ps1DOHUQEfwnShDyiHzd1R QxFsM43bvD5Uas/Va54D6dYqM+lqTEL4hn+mTdbqaDX+hR/qhwnLvn9xHSPEtp0EDdOR UHlSQ98tWpMHu8rdH+B7Dpir3eNM7O5JE4ZXrFIbcPcb4yp6FM0XIvWQixX/tEDjXPEK lFCw== X-Gm-Message-State: AO0yUKXTklddZVA9hrSzem/pALgOZkH/HWw79MDWY3TYbx+kXt95v7BR +5zLHxKXSJB7b4VEzAjy+aZpe6e11IIRndc7 X-Google-Smtp-Source: AK7set/QBN3gCSQjjXeisIcUaBGfIehO6EhsfDzeZwr+GlB9papeeKz2zBmA8ws2JmR5FCwWKKlJ6A== X-Received: by 2002:a17:906:5dad:b0:8b1:3a18:9daf with SMTP id n13-20020a1709065dad00b008b13a189dafmr4951976ejv.74.1678821245634; Tue, 14 Mar 2023 12:14:05 -0700 (PDT) Original-Received: from parmenides (ip-89-177-55-133.bb.vodafone.cz. [89.177.55.133]) by smtp.gmail.com with ESMTPSA id v10-20020a50a44a000000b004fd204d180dsm1444898edb.64.2023.03.14.12.14.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 12:14:05 -0700 (PDT) In-Reply-To: <87r0trb2pz.fsf@gmail.com> Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=matus.goljer@gmail.com; helo=mail-ed1-x531.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-Mailman-Approved-At: Tue, 14 Mar 2023 15:52:14 -0400 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:304461 Archived-At: > Maybe it's more useful to allow negative arguments in seq-elt? Saying > (seq-elt seq -1) isn't much more effort than (seq-last seq). I'm personally a bit ambiguous about negative indices. It's nice for those one liners when you need them, but they are quite confusing especially if you switch between languages and they all implement them a bit differently. Sometimes having simple semantics of "last item" is better for understanding the code 6 months down the line or when just skimming through. But of course we can have both. Emacs itself has `car` but `nth 0` also works. >>> I think for lists it should behave as `nth` or `elt`, so it gives nil. >> >> But why? Wouldn't that be a leaky abstraction, since the behaviour >> doesn't consistently abstract over the concrete sequence types? If code >> doesn't want to worry about what sequence is being used, then it has to >> manually check the return value or if a signal was raised, depending on >> the type of the argument to seq-last (which is to ignore the issue that >> we cannot distinguish between (seq-first '()) and (seq-first '(nil)), >> the same also being the case for seq-last). > > It would be good to look systematically at what errors seq.el can > signal. But it also seems that in practice the main value of seq.el is > to provide a bunch of handy functions rather than allowing you to work > with a sequence whose type you don't know. Yea, this has been my experience as well. Usually I know what the sequence is, but seq provides a nice interface to not have to *remember* how to do what I need. Just seq-do it and it will work somehow. --=20 Best regards, Mat=C3=BA=C5=A1 Goljer