Subject: Re: bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?

From: David Ponce <[email-masked]>
Date: Thu, 1 May 2025 17:51:49 +0200

On 2025-04-30 11:28, David Ponce wrote:
> On 2025-04-29 20:02, Stefan Monnier wrote:
>> Further comments:
>>
>> - For a declaration like
>>
>>      (cl-deftype list-of (elem-type)
>>        `(and list
>>              (satisfies ,(lambda (list)
>>                            (cl-every (lambda (elem) (cl-typep elem elem-type))
>>                                      list)))))
>>    we add the type to `cl--type-list` even though it's unusable there
>>    (the `cl-typep` call in `cl-types-of` will always signal an error
>>    because the type can't be used without argument).
>>

>> - One way to solve the problem with `list-of` (and even open up the
>>    possibility to dispatch on complex types like `(list-of FOO)`) is to
>>    populate `cl--type-dispatch-list` (i.e. the list of types that need to
>>    be checked during dispatch) from `cl-generic-generalizers` so it
>>    includes only those types for which there's a method, rather than all
>>    defined types.
>>

Please find attached a version of cl-types.el with my first try at
implementing something related to your idea above to populate a
`cl--type-dispatch-list' from `cl-generic-generalizers'.

Changes are at the end of the file in the last section "Method dispatching".
I hope I started understanding your idea ;-)

Thanks!
David