help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: How to specialize seq-concatenate and seq-into-sequence?


From: Philipp Stephani
Subject: Re: How to specialize seq-concatenate and seq-into-sequence?
Date: Fri, 4 Mar 2022 21:56:12 +0100


> Am 04.03.2022 um 03:35 schrieb Michael Heerdegen <michael_heerdegen@web.de>:
> 
> Philipp Stephani <p.stephani2@gmail.com> writes:
> 
>>> Define `it`.
>>> The dispatch is expected to be on the `type` argument (using an
>>> `eql` specializer).
>>> 
>> 
>> Doesn't that contradict the docstring?
> 
> I'm also a bit confused.  How would you concatenate a list and a stream
> to a list?  Or how would you implement it?

I guess the idea is that `seq-concatenate' can only be specialized for new 
*result* types, not for new *argument* types.  That is, if you have a new 
sequence-like type `my-sequence', you can specialize it like so:

(cl-defmethod ((_type (eql my-sequence)) &rest sequences)
  (my-sequence-concatenate (mapcar #'convert-to-my-sequence sequences)))

where `my-sequence-concatenate' and `convert-to-my-sequence' are functions 
specific to the new sequence type.  It's not possible to convert a 
`my-sequence' to a list this way; for that you'd need to specialize `seq-into' 
or `seq-into-sequence' instead.


reply via email to

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