emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sequence manipulation functions


From: Stefan Monnier
Subject: Re: sequence manipulation functions
Date: Wed, 05 Nov 2014 10:26:16 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

> Here are two files that add some missing sequence-manipulation functions
> to Emacs Lisp.

I think these should use a "seq-" prefix.  This will not only avoid
naming conflicts, but also helps discover those functions, since you can
type `(seq- TAB' to see all related functions.

> ;;; Commentary:
>
> ;; Sequence manipulation functions

No need to repeat the title here.

> ;;;###autoload

It seems that pretty much all functions in this file are marked
as ;;;###autoload.  In that case I think it's better to not mark any of
them as autoloaded.

> (defun rest (seq)
>   "Return all but the first element of the sequence SEQ.
> If SEQ is nil or empty, return nil."

The different of cost between "rest of a list" and "rest of an array" is
so large that merging the two this way is probably not a good idea.

>   "Reduce two-argument FUNCTION across SEQ, starting with INITIAL-VALUE if 
> not nil."
>   (let ((acc (or initial-value (if (empty-p seq)
>                                    (funcall function)

You start by saying "two-argument FUNCTION" and then you call it here
without any argument.

>     (mapc (lambda (item)
>             (setq acc (funcall function acc item)))
>           (if initial-value seq (rest seq)))

I don't think using `rest' here is a good idea when`seq' is an array.

>   "Sort the sequence SEQ comparing elements using PRED."

It needs to say that it returns a list rather than a sequence of the
same type as SEQ.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]