* 'head' specializer for cl-defmethod?
@ 2015-07-28 12:06 Stephen Leake
2015-07-28 20:39 ` Dmitry Gutov
2015-07-29 0:01 ` Stefan Monnier
0 siblings, 2 replies; 3+ messages in thread
From: Stephen Leake @ 2015-07-28 12:06 UTC (permalink / raw)
To: emacs-devel
project.el uses a 'head' specializer in the dispatching argument of
cl-defmethod.
This use of 'head' is not documented other than in the 'Added elements'
section of the cl-generic.el header comment.
I'd like to change the cl-defmethod doc
string to say:
Other than a type, TYPE can also be one of the following:
- `(eql VAL)' - this method will be invoked when the
argument is `eql' to VAL.
- `(head VAL)' - this method will be invoked when the `car' of the
argument is `eql' to VAL
However, that still leaves out the eieio-core specializer `subclass';
I'm not clear how to handle that in the doc string.
I'm guessing the rationale for supporting the 'head' specializer is to
allow using cl-defmethod with objects that are constructed by `cons',
without any cl-defstruct or eieio defclass. That's how it is used in
project.el.
Is there a manual section for cl-defmethod? I don't see one in
doc/misc/cl.texi; perhaps we should add one?
--
-- Stephe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'head' specializer for cl-defmethod?
2015-07-28 12:06 'head' specializer for cl-defmethod? Stephen Leake
@ 2015-07-28 20:39 ` Dmitry Gutov
2015-07-29 0:01 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Gutov @ 2015-07-28 20:39 UTC (permalink / raw)
To: Stephen Leake, emacs-devel
On 07/28/2015 03:06 PM, Stephen Leake wrote:
> This use of 'head' is not documented other than in the 'Added elements'
> section of the cl-generic.el header comment.
This statement is also probably outdated: "and all methods of NAME have
to use the same argument for dispatch". At least I can use a dispatch on
an argument together with dispatch on &context (which also needs to be
documented).
> Is there a manual section for cl-defmethod? I don't see one in
> doc/misc/cl.texi; perhaps we should add one?
We should.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: 'head' specializer for cl-defmethod?
2015-07-28 12:06 'head' specializer for cl-defmethod? Stephen Leake
2015-07-28 20:39 ` Dmitry Gutov
@ 2015-07-29 0:01 ` Stefan Monnier
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2015-07-29 0:01 UTC (permalink / raw)
To: Stephen Leake; +Cc: emacs-devel
> I'd like to change the cl-defmethod doc
> string to say:
> Other than a type, TYPE can also be one of the following:
> - `(eql VAL)' - this method will be invoked when the
> argument is `eql' to VAL.
> - `(head VAL)' - this method will be invoked when the `car' of the
> argument is `eql' to VAL
> However, that still leaves out the eieio-core specializer `subclass';
> I'm not clear how to handle that in the doc string.
Actually, the docstring should be dynamically generated (like the
one of `pcase') to show the various options, since these can be extended
by third party packages.
Stefan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-29 0:01 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-28 12:06 'head' specializer for cl-defmethod? Stephen Leake
2015-07-28 20:39 ` Dmitry Gutov
2015-07-29 0:01 ` Stefan Monnier
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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).