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 16:48:43 +0100 Message-ID: <87wn3jl4f8.fsf@gmail.com> References: <871qlrmr14.fsf@gmail.com> <87fsa7cq0v.fsf@posteo.net> 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="5195"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 14 17:19:28 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 1pc7N2-000160-6F for ged-emacs-devel@m.gmane-mx.org; Tue, 14 Mar 2023 17:19:28 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pc7Ma-0002kh-Ro; Tue, 14 Mar 2023 12:19:00 -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 1pc6tQ-0006Hz-Rx for emacs-devel@gnu.org; Tue, 14 Mar 2023 11:48:52 -0400 Original-Received: from mail-ed1-x536.google.com ([2a00:1450:4864:20::536]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pc6tM-0000r3-5Y for emacs-devel@gnu.org; Tue, 14 Mar 2023 11:48:52 -0400 Original-Received: by mail-ed1-x536.google.com with SMTP id r11so12222410edd.5 for ; Tue, 14 Mar 2023 08:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678808926; 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=xWKW9jnheVuUiH1Va38lTsVx68uCfFEdVm5sxzJOXQA=; b=j/TGvNNHevYejvM7AJl0BEJ04G9ymNtavnMjMSj79qbABOTJqHGNAc5QKFd6mOxJUF 1xWl+chB6sN7OzQg8GSSMw9n36O61VbYg6Wm/ohsXUPm6JW6c4S64GnEles9aEmyM6jc kLLQNjXEGyw7HsljWNanvCWhRXgfZ+C/GqhOzjgyVK6UxyR+lj6sVm6oJ4ttSwKqUDnR f0zkz4hHcNeT+1FY9r6o2ARlg93otOjHu0NGFuQO99mdSYgoQbNh9Iy4XA7QnMPDtZS/ YpjYId1vmmSF+/5agDNJm0XFPIvPBvO7TC5uMPuEGSY7dSKwQi8EhrUOM4Q8NLGT4RAT LU6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678808926; 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=xWKW9jnheVuUiH1Va38lTsVx68uCfFEdVm5sxzJOXQA=; b=Q4PRZiw2fAco1rQiEWv3AMw+Oq1L8Vn5pEyJ7R1YyVsnQVWq1Vjb0/mvTiQGl5Exhr nMxT1Yu/tz73MzsyqkEa2HsKXTXT1/rGoCGsczM4SdJaKQHB7mlHcIDi0itL0iZy/t6g 8U3UqW+UjBLBUbFFCjetTthxNxbsFTvW3LAGZM5EGsvyr7qTGn+OXALfG71JkEp6Dc5r nYZHzZIJ5GmG6s6C72mmkIBinmpGUlbUibKSYMMr+iPkLG6NYSBOAfmokVD2qjql9WWa kyeZlmE6QFj4Iv32foKCQG1WP0kYoC7/VioMU67QjAZjEZ/1vBQVw+TRn9IqkTTsRrCb wLgA== X-Gm-Message-State: AO0yUKWqwkCXUk8kX5kgsjbVPq+5PxGtXyFMoZvnXLn1+YhkXCOZrHGx KJzbhcBE60ujOoV/UYwv5Hod2dXec0TEIg== X-Google-Smtp-Source: AK7set+eN0NGf6iT7JjwpFnjP46oFcA0TfbdQCbnLEGjSlbafF5AFDk8eq1n74rHHHnyYzARbMdANQ== X-Received: by 2002:a17:906:b7d8:b0:927:d9ad:804d with SMTP id fy24-20020a170906b7d800b00927d9ad804dmr3129047ejb.7.1678808925867; Tue, 14 Mar 2023 08:48:45 -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 v11-20020a1709062f0b00b00914fec9f40esm1312230eji.71.2023.03.14.08.48.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Mar 2023 08:48:45 -0700 (PDT) In-Reply-To: <87fsa7cq0v.fsf@posteo.net> Received-SPF: pass client-ip=2a00:1450:4864:20::536; envelope-from=matus.goljer@gmail.com; helo=mail-ed1-x536.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 12:18:58 -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:304452 Archived-At: > Wouldn't it make sense to add a specialised implementation for lists, to > avoid recusing the list twice. I can turn it into defgeneric with default implementation same as what I provided and special instance for a list, that makes sense. Although I wonder what the performance impact is of the dispatch vs iterating a list /shrug. > A thing I notice is that seq-first is not consistent on the way it > behaves if the sequence is empty. > > (seq-first '()) ;=3D> nil > > while > > (seq-first []) > > raises an error. seq-last would have the same issue for vectors, except > that it would attempt to index the position -1, which might be > confusing? I think for lists it should behave as `nth` or `elt`, so it gives nil. I agree that the error with -1 for vector might be confusing. Should we instead raise our own (seq) error for empty vector with seq-first and seq-last? Not sure what would be the best way. I should also add some tests, I've noticed there was a test file for seq. Should I resubmit this patch with the feedback incorporated to bug-gnu-emacs@gnu.org instead? I'm not sure if emacs-devel is the place, sorry T_T. --=20 Best regards, Mat=C3=BA=C5=A1 Goljer