[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] seq.el: add seq-last for symmetry with seq-first
From: |
Matúš Goljer |
Subject: |
Re: [PATCH] seq.el: add seq-last for symmetry with seq-first |
Date: |
Tue, 14 Mar 2023 16:48:43 +0100 |
> 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 '()) ;=> 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.
--
Best regards,
Matúš Goljer
- [PATCH] seq.el: add seq-last for symmetry with seq-first, Matúš Goljer, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first,
Matúš Goljer <=
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Augusto Stoffel, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Matúš Goljer, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/14
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Augusto Stoffel, 2023/03/15
- Re: [PATCH] seq.el: add seq-last for symmetry with seq-first, Philip Kaludercic, 2023/03/15