all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* How to do defmethod dispatch based on the type of a struct's slot?
@ 2024-05-04 21:57 Okamsn
  2024-05-05 10:55 ` Michael Heerdegen via Users list for the GNU Emacs text editor
  0 siblings, 1 reply; 2+ messages in thread
From: Okamsn @ 2024-05-04 21:57 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Hello,

I am trying to test using a `cl-defstruct` structure to represent a 
sub-sequence, which would implement `seq-map`. In the structure, I have 
a slot that contains the original sequence. I would like to be able to 
use different forms of `seq-map` based on the type of the original 
sequence. I am having trouble understanding how to create a specializer 
and a generalizer for this.

Is there a way to create a specializer for `cl-defmethod`, something 
like `(cl-defmethod seq-map (function (sequence (my-test-subseq array))) 
...)` ?

I have tried using a type defined via `cl-deftype` as the specializer 
using the `satisfies` type, but that did not seem work. Do types defined 
via `cl-deftype` work as specializers?

Thank you.





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: How to do defmethod dispatch based on the type of a struct's slot?
  2024-05-04 21:57 How to do defmethod dispatch based on the type of a struct's slot? Okamsn
@ 2024-05-05 10:55 ` Michael Heerdegen via Users list for the GNU Emacs text editor
  0 siblings, 0 replies; 2+ messages in thread
From: Michael Heerdegen via Users list for the GNU Emacs text editor @ 2024-05-05 10:55 UTC (permalink / raw)
  To: help-gnu-emacs

Okamsn <okamsn@protonmail.com> writes:

> Hello,
>
> I am trying to test using a `cl-defstruct` structure to represent a 
> sub-sequence, which would implement `seq-map`. In the structure, I have 
> a slot that contains the original sequence. I would like to be able to 
> use different forms of `seq-map` based on the type of the original 
> sequence. I am having trouble understanding how to create a specializer 
> and a generalizer for this.

'STRUCT-TYPE' is not possible as specializer?

> I have tried using a type defined via `cl-deftype` as the specializer 
> using the `satisfies` type, but that did not seem work. Do types defined 
> via `cl-deftype` work as specializers?

Not out of the box AFAIU.

Michael.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-05 10:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-04 21:57 How to do defmethod dispatch based on the type of a struct's slot? Okamsn
2024-05-05 10:55 ` Michael Heerdegen via Users list for the GNU Emacs text editor

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.