From: Nicolas Petton <petton.nicolas@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Emacs developers <emacs-devel@gnu.org>
Subject: Re: [PATCH] sequence manipulation functions
Date: Mon, 10 Nov 2014 23:28:37 +0100 [thread overview]
Message-ID: <87k332u1uy.fsf@gmail.com> (raw)
In-Reply-To: <jwvegtbt2ft.fsf-monnier+emacs@gnu.org>
Thank you Stefan for your review. I will submit another patch shortly.
Nico
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> +;; Sequence manipulation functions
>
> As noticed in the previous review, this just repeats what's already on
> the first line, so that's not useful. OTOH An important info would be
> to define what we mean by "sequence" here, more specifically which kinds
> of sequences are supported.
>
> Also we could document here the conventions that we tried to follow.
> E.g. what is the argument ordering.
>
>> +(require 'pcase)
>
> Why? The `pcase' macro is autoloaded, so you should only need to
> (require 'pcase) if you want top use macros like pcase-dolist.
>
>> +(defun seq-filter (pred seq)
>> + "Return a list filtering with PRED all elements of SEQ."
>
> Doesn't say if PRED returning nil means "keep" or "throw away".
>
>> + (delq nil (mapcar (lambda (elt)
>> + (and (funcall pred elt) elt))
>> + seq)))
>
> This will filter out the nil elements, regardless of `pred'.
>
>> +(defun seq-reduce (function seq &optional initial-value)
>> + "Reduce FUNCTION across SEQ, starting with INITIAL-VALUE if not nil."
>
> You don't say how FUNCTION will be called.
>
>> + (or (listp seq) (setq seq (append seq '())))
>> + (let ((acc (or initial-value (if (seq-empty-p seq)
>> + (funcall function)
>> + (car seq)))))
>
> If you want an initial value of nil but your function can only be called
> with 2 arguments, you're screwed :-(
> Would it be a real problem if we simply made `initial-value' an
> mandatory argument?
>
>> +(defun seq-some-p (pred seq)
>> + "Return any element for which PRED is true in SEQ, nil otherwise."
> ^^^^
> Usually we say "non-nil".
>
>> + (catch 'seq-some-p-break
>
> Since this tag is internal, I'd use a "seq--" prefix. I think
> `seq--break' should be sufficient. Of course you could also just use
> cl-block and cl-return and circumvent the question.
>
>> +(defun seq-every-p (pred seq)
>> + "Return t if (PRED item) is non-nil for all elements of the sequence SEQ."
> ^
> non-nil
>
>> +(defun seq-empty-p (seq)
>> + "Return t if the sequence SEQ is empty, nil otherwise."
> ^
> non-nil
>
>> +(defun seq-sort (seq pred)
>> + "Return a sorted list of the elements of SEQ compared using PRED."
>
> I wonder if that's really the more useful behavior, compared to the
> "inplace" sorting of `sort', or compared to the alternative is always
> returning a new sequence, but of the same type as the `seq' argument.
>
>> +(defun seq-concatenate (type &rest seqs)
>> + "Concatenate, into a sequence of type TYPE, the argument SEQS.
>> +\n(fn TYPE SEQUENCE...)"
>
> You need to document the values that TYPE can take. Maybe you can
> simply refer to `type-of'.
>
>> +(defalias 'seq-copy #'copy-sequence)
>> +(defalias 'seq-elt #'elt)
>> +(defalias 'seq-length #'length)
>
> I think mapc would make a lot of sense, and I guess mapcar as well.
> Not sure if we should name them `seq-mapc' and `seq-mapcar' or
> something else.
>
>> +(load "emacs-lisp/sequences")
>
> I think I'd rather not preload it for now and let people use (require
> 'seq) for that. There's 30 years of accumulated Elisp code and we're
> not going to switch them to use a new naming scheme overnight. It might
> even be that people will simply not like to have to add "seq-" in their
> code (I know they complained about adding "cl-"), so I'd start by simply
> providing the library and when its popularity grows (and/or is being
> used by preloaded code) we can then add it to loadup.
>
>
> Stefan
--
Nicolas Petton
http://nicolas-petton.fr
next prev parent reply other threads:[~2014-11-10 22:28 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-04 22:17 sequence manipulation functions Nicolas Petton
2014-11-05 1:21 ` Glenn Morris
2014-11-05 9:46 ` Nicolas Petton
2014-11-05 4:58 ` Richard Stallman
2014-11-05 9:45 ` Nicolas Petton
2014-11-06 0:54 ` Daniel Colascione
2014-11-05 9:23 ` Damien Cassou
2014-11-05 18:12 ` Richard Stallman
2014-11-05 21:59 ` Nicolas Petton
2014-11-05 22:40 ` Stefan Monnier
2014-11-06 0:30 ` Richard Stallman
2014-11-05 15:26 ` Stefan Monnier
2014-11-05 15:36 ` Nicolas Petton
2014-11-05 15:52 ` Sebastien Vauban
2014-11-05 18:32 ` Stefan Monnier
2014-11-07 17:35 ` [PATCH] " Nicolas Petton
2014-11-07 17:43 ` Daniel Colascione
2014-11-10 17:41 ` Stefan Monnier
2014-11-10 22:28 ` Nicolas Petton [this message]
2014-11-10 23:12 ` Nicolas Petton
2014-11-11 2:20 ` Stefan Monnier
2014-11-12 17:49 ` Nicolas Petton
2014-11-12 19:12 ` Bozhidar Batsov
2014-11-12 19:30 ` Nicolas Petton
2014-11-12 20:28 ` Stefan Monnier
2014-11-12 20:56 ` Nicolas Petton
2014-11-12 23:06 ` Nicolas Petton
2014-11-12 23:17 ` Nic Ferrier
2014-11-13 1:29 ` Leo Liu
2014-11-13 5:21 ` Drew Adams
2014-11-14 5:16 ` Leo Liu
2014-11-16 12:52 ` Bozhidar Batsov
2014-11-16 14:16 ` Nicolas Petton
2014-11-16 17:22 ` Drew Adams
2014-11-16 19:13 ` Stefan Monnier
2014-11-17 2:52 ` Richard Stallman
2014-11-17 11:46 ` Nicolas Petton
2014-11-17 13:53 ` Stefan Monnier
2014-11-16 7:38 ` Damien Cassou
2014-11-20 23:16 ` Stefan Monnier
2014-11-21 12:40 ` Nicolas Petton
2014-11-21 13:11 ` Stefan Monnier
2014-11-21 13:28 ` Nicolas Petton
2014-11-21 14:44 ` Stefan Monnier
2014-11-24 17:49 ` Nicolas Petton
2014-11-24 18:01 ` Nicolas Petton
2014-11-05 16:25 ` Drew Adams
2014-11-05 17:21 ` Artur Malabarba
2014-11-05 18:27 ` Drew Adams
2014-11-05 17:22 ` Damien Cassou
2014-11-05 18:28 ` Drew Adams
2014-11-05 17:41 ` Nicolas Petton
2014-11-05 18:23 ` Tom Tromey
2014-11-05 18:29 ` Drew Adams
2014-11-05 18:29 ` Drew Adams
2014-11-06 4:39 ` Richard Stallman
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87k332u1uy.fsf@gmail.com \
--to=petton.nicolas@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.