unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Augusto Stoffel <arstoffel@gmail.com>
To: Philip Kaludercic <philipk@posteo.net>
Cc: "Matúš Goljer" <matus.goljer@gmail.com>, emacs-devel@gnu.org
Subject: Re: [PATCH] seq.el: add seq-last for symmetry with seq-first
Date: Wed, 15 Mar 2023 08:06:20 +0100	[thread overview]
Message-ID: <87mt4ebij7.fsf@gmail.com> (raw)
In-Reply-To: <87edprm1l0.fsf@posteo.net> (Philip Kaludercic's message of "Tue,  14 Mar 2023 22:04:43 +0000")

On Tue, 14 Mar 2023 at 22:04, Philip Kaludercic wrote:

>>> 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.
>
> The only language I am really familiar with is python, and what that
> effectively does is (mod i (length n)), what do other languages do?

In Python "abc"[-4] throws and error.  I don't think there's any choice
to be made here: If it were to support a negative index n, then
(seq-elt s n) should just return the (+ (length s) n)-th element, with
the usual treatment for out of bounds indices (whatever it is).

> Another thing that should be kept in mind that sequences can be streams
> (as provided by stream.el), and there doesn't have to be a final
> element.

What is the seq-length of an infinite stream?  And does asking for the
length of a stream consume it?  If so, then seq is an imperfect
abstraction for streams.



  reply	other threads:[~2023-03-15  7:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-14 12:55 [PATCH] seq.el: add seq-last for symmetry with seq-first Matúš Goljer
2023-03-14 15:26 ` Philip Kaludercic
2023-03-14 15:48   ` Matúš Goljer
2023-03-14 16:14     ` Philip Kaludercic
2023-03-14 18:35       ` Augusto Stoffel
2023-03-14 19:14         ` Matúš Goljer
2023-03-14 22:04         ` Philip Kaludercic
2023-03-15  7:06           ` Augusto Stoffel [this message]
2023-03-15  8:09             ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mt4ebij7.fsf@gmail.com \
    --to=arstoffel@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=matus.goljer@gmail.com \
    --cc=philipk@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).