[Top][All Lists]

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

Re: cl-defmethod specializer widget ?

From: Stefan Monnier
Subject: Re: cl-defmethod specializer widget ?
Date: Thu, 27 Jan 2022 01:28:46 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

> I wonder why it is not possible to use widget as specializer in cl-defmethod.

Because the current code only works for types that can be inferred
solely from the value of (type-of OBJ), basically.

You can add support for `widget` as a specializer in two ways:
- Redefine widgets to use their own *real* type (i.e. with
  `cl-defstruct`) instead of (ab)using symbols and cons cells.
- Add a method to `cl-generic-generalizers` to handle `widget` in an
  ad-hoc way.

> Indeed it is not declared in the suitable list but could
> it be added without trouble ;

It would slow down dispatch, but only of those generic functions that
contain methods specializing on `widget`.

> Similarly function is not accepted but it could be comfortable .

Indeed, for the same reason: a value of the form (closure ...) or
(lambda ...) is a valid function, currently, but `type-of` returns
`cons` and not all `cons` are functions, so it would require
an additional method in `cl-generic-generalizers`.


reply via email to

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