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 01:11:02 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

On 14/11/2023 04:27, João Távora wrote:
This is all interesting, until one ponders what happens if an existing
seq.el user somewhere has:

(cl-defmethod seq-contains-p ((seq my-voodoo-seq)
                               (elt (eql :secret-voodoo)) &optional _tesfn)
   (invoke-voodoo-priests seq))

making use of seq.el's support for abstract polymorphic sequences.

With seq.el 2.24 a seq-difference operation would consider this user's
method, with seq.el 2.24.dmitry (i.e. your fast seq-difference-3) it
simply won't.  This user's code is clearly broken.

But was the user allowed to do that in the first place?  If not,
why is seq-contains-p a public generic function?

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.

So the author of the new data type (who works on the implementation of seq-do and specialized methods) is responsible for making sure the new definition is equivalent but faster.

This is not documented, but seems to hold for all the code in the package. If someone found a case where violating the above rule would be helpful for a certain practical purpose, we could discuss it.

Note that all the functions in seq.el are currently non-destructive or perhaps even "pure", so it's not like there could be something special done to the input data behind the scenes, aside from what's in the contract (data in + data out).



reply via email to

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