emacs-devel
[Top][All Lists]
Advanced

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

Re: behaviour change in cl-subseq


From: Artur Malabarba
Subject: Re: behaviour change in cl-subseq
Date: Fri, 21 Aug 2015 01:02:18 +0100

> (defun seq-contains-p (seq elt &optional testfn)
>   "Return the first element in SEQ that equals to ELT.
> Equality is defined by TESTFN if non-nil or by `equal' if nil."
>   (seq-some-p (lambda (e)
>                 (funcall (or testfn #'equal) elt e))
>               seq))
>
> Two issues. Implementation wise, you are depending on behaviour outside
> the interface of seq-some-p which says....
>
> "Return any element for which (PRED element) is non-nil in SEQ, nil
>   otherwise."
>
> The other option is to add a `seq-contains-nil-p' function.
>
> Personally, I'd change seq-contains-p. Better to break the interface of
> seq-contains-p earlier rather than later.

I think both functions need to change behavior. They are named as
`-p', but "return an element" is not the behavior of a boolean
predicate (precisely because of the situation you describe).

IMO, the current behavior of `seq-some-p' should be called `seq-some'.
And the same for `seq-contains'.



reply via email to

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