emacs-devel
[Top][All Lists]
Advanced

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

Re: What's missing in ELisp that makes people want to use cl-lib?


From: Dmitry Gutov
Subject: Re: What's missing in ELisp that makes people want to use cl-lib?
Date: Wed, 15 Nov 2023 02:46:06 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 15/11/2023 01:52, João Távora wrote:
On Tue, Nov 14, 2023 at 11:11 PM Dmitry Gutov <dmitry@gutov.dev> wrote:

Allow me to try to answer this again: special voodoo is probably not
allowed. What the specialized methods are supposed to do is implement
the same logic (described in the generic function's docstring) but in a
more efficient manner.

But isn't my method just that?

It's a good style, but any specific project's requirements might differ, and libraries often have to get defensive against bad practices, too.

Let's say the methods's is simpler,
like this:

(cl-defmethod seq-contains-p ((seq my-voodoo-seq)
                                 (elt (eql :secret-voodoo)) &optional _tesfn)
     ;; my-voodoo-seq always has :secret-voodoo.
     t)

Hard to be more efficient than that, right?  Then I could use

(seq-difference '(1 2 3 :secret-voodoo 5) (make-a-voodoo-seq))

And get any voodoo out.

Okay... so a voodoo seq contains the :secret-voodoo keyword (maybe once, maybe several times, but not any other element).

Then it must have a seq-do implementation that yields :secret-voodoo one or several times. And then the seq-contains-pred implementation will do right by it (the default one, not the specialization for lists).

This is not documented,

You don't say? :-)  i think we should get started on documenting all
these ad-hoc rules (sorry but in this case they are quite literally
ad-hoc).  Better than nothing, I guess, since as to actually enforcing
them, I think that train has left the station a long time ago and is
now in a voodoo swamp in monkey island.

Not sure "enforcing them" is the right phrase: I wonder if there's ever been a change proposed to seq.el which would break them.

Anyway, documenting them sounds best. As soon as we can arrive on a phrasing that sounds clear to all interested parties.

Anyway, I'll be back with more custom sequences soon.

Please do.



reply via email to

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