From: Stefan Monnier via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org>
To: help-gnu-emacs@gnu.org
Subject: Re: cl-defmethod specializer widget ?
Date: Thu, 27 Jan 2022 01:28:46 -0500 [thread overview]
Message-ID: <jwv1r0tya1q.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: 86v8y6d1x0.fsf@pollock-nageoire.net
> 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`.
Stefan
next prev parent reply other threads:[~2022-01-27 6:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-26 14:09 cl-defmethod specializer widget ? Pierre L. Nageoire
2022-01-27 6:28 ` Stefan Monnier via Users list for the GNU Emacs text editor [this message]
2022-01-28 6:35 ` Pierre L. Nageoire
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=jwv1r0tya1q.fsf-monnier+emacs@gnu.org \
--to=help-gnu-emacs@gnu.org \
--cc=monnier@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).