[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-g
From: |
David Ponce |
Subject: |
bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic? |
Date: |
Fri, 11 Apr 2025 09:14:41 +0200 |
User-agent: |
Mozilla Thunderbird |
Hello
In the cl-generic library, the implementation of the
`cl-generic-generalizers' "typeof" method, used to dispatch
"normal types", mentions in a FIXME on line 1367: "Add support for
other "types" accepted by `cl-typep' such as `character', `face',
`keyword', ...?".
As part of some other works, I created the attached "gtype" library,
which complements `cl-deftype' so that such defined types are also
recognized as argument types for dispatching generic function methods.
Here is a quick example of use:
(defgtype face nil ()
"A face type."
'(satisfies facep))
(gtype-of 'default)
=> face
(cl-type-of 'default)
=> symbol
(cl-defmethod my-add-face ((text string) (face face))
(propertize text 'face face))
=> my-add-face
(my-add-face "text" 'bold)
=> #("text" 0 4 (face bold))
(my-add-face "text" 'bad-face)
=> No applicable method: add-face, "text", bad-face
I've been using this library successfully in some of my code, and was
wondering if it could help add this functionality to Emacs. My goal
is not to include this library, but to use it as a starting point for
further reflection on this subject.
My library is relatively concise and adopts a design similar to that
used for built-in types. The new types (which I call "gtypes") are
instances of the structure `gtype-class', derived from `cl--class',
just as built-in types are instances of the structure `built-in-class'
also derived from `cl--class'. gtypes thus benefits from the existing
infrastructure used for other types. I also chose to have a separate
"generalizer" for gtypes. I'm not sure if it would be desirable to
extend the existing generalizer "typof" to support such types.
I would therefore be interested in hearing more expert opinions on
my implementation and whether it could help add this functionality to
cl-generic, if it makes sense.
Thank you for your time.
gtype.el
Description: Text Data
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?,
David Ponce <=
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Eli Zaretskii, 2025/04/11
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Stefan Monnier, 2025/04/11
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, David Ponce, 2025/04/11
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Stefan Monnier, 2025/04/11
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, David Ponce, 2025/04/13
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Stefan Monnier, 2025/04/13
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, David Ponce, 2025/04/13
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Stefan Monnier, 2025/04/13
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, David Ponce, 2025/04/14
- bug#77725: 31.0.50; Add support for types accepted by `cl-typep' to cl-generic?, Stefan Monnier, 2025/04/14