unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Philipp Stephani <p.stephani2@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: help-gnu-emacs@gnu.org
Subject: Re: How to specialize seq-concatenate and seq-into-sequence?
Date: Fri, 4 Mar 2022 21:56:12 +0100	[thread overview]
Message-ID: <4F58A846-36B5-4D52-88A1-9D6F63773679@gmail.com> (raw)
In-Reply-To: <871qzibg2a.fsf@web.de>



> 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.


  parent reply	other threads:[~2022-03-04 20:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-03 15:50 How to specialize seq-concatenate and seq-into-sequence? Philipp Stephani
2022-03-03 17:40 ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-03-03 20:49   ` Philipp Stephani
2022-03-04  0:20     ` Stefan Monnier
2022-03-04  0:48       ` Philipp Stephani
2022-03-04  2:35         ` Michael Heerdegen
2022-03-04 14:31           ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-03-04 22:12             ` Michael Heerdegen
2022-03-04 23:02               ` Stefan Monnier via Users list for the GNU Emacs text editor
2022-03-04 20:56           ` Philipp Stephani [this message]
2022-03-04 21:54             ` Michael Heerdegen
2022-03-04 13:31         ` Stefan Monnier

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=4F58A846-36B5-4D52-88A1-9D6F63773679@gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=help-gnu-emacs@gnu.org \
    --cc=michael_heerdegen@web.de \
    /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).