Subject: Re: bug#78989: 31.0.50; classes and methods inheritance (defclass) seq-contains-p

From: Stefan Monnier <[email-masked]>
Date: Mon, 14 Jul 2025 13:14:35 -0400

> 1. cl-defmethods that overlap but aren't ordered by the inheritance
> graph (rather than by the order of inheritance) cause a warning.
[...]
> Doing (1) even at definition time is probably expensive,

I think the problem here is not just whether it's expensive but that
the compiler will often not be able to see the conflict because the
it is only visible when:

- Method for A is defined.
- Method for B is defined.
- Class that inherits from both A and B is defined.

And those three will often live in separate files and may not
necessarily require each other.

> and doing it at invocation time, I expect, prohibitively so.

Not necessarily, actually, no.  I think it shouldn't be terribly
hard/costly to compute (e.g. inside `eieio-defclass-internal`) a list of
pairs of parent classes that are "unordered".

Then when computing the effective method we would have to compare the
list of active methods with that list of pairs of "unordered" classes.
It would be costly to do that at every call, but doing it only when
computing the effective methods should make it quite tolerable.

There is a minor issue of actually writing the code, especially because
the relevant code in `cl-generic.el` is used not just for classes but
for any kind of "specializer", but that's just a question of devising
the right API for it (since the same need exists for other kinds of
specializers).

        Stefan