emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] sequence manipulation functions


From: Nicolas Petton
Subject: Re: [PATCH] sequence manipulation functions
Date: Tue, 11 Nov 2014 00:12:23 +0100
User-agent: mu4e 0.9.9.6pre3; emacs 24.3.1

Stefan Monnier <address@hidden> writes:
>
>> +  (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?

No, I think that's fine.

>> +  (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.

Sure, I will use seq--break.

>> +(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.

I can make it return a sequence of the same type as seq. I don't want to
sort in place though, all other functions leave seq untouched, and I
would like to keep it this way.

>> +(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.

How do "seq-do" and "seq-map" sound like?

I'm not confortable with "seq-doseq" or something like that since I
would expect it to be a macro similar to "dolist".

>
>> +(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.

Fair enough. One question though, if sequences.el is not preloaded, then
I guess these functions should not be documented in the manual? But
then, how will people find out about it? If nobody knows about it, then
it makes it much less likely to be used :)

Nico

-- 
Nicolas Petton
http://nicolas-petton.fr




reply via email to

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