[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master c13a4df: Remove the calls to `seq-into` from `s
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] master c13a4df: Remove the calls to `seq-into` from `seq-concatenate` |
Date: |
Tue, 25 Aug 2015 17:52:47 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
>>> Yes, it is still a problem. One solution would be to test if the seq is
>>> a cl-struct with, in which case we could use `seq-into'. But then that
>>> would only fix the cl-struct case, not any other.
>> If we make it into a defmethod, at least it would be possible for
>> specific cl-structs to fix the problem.
> It is already, or did you mean something else? But how would you do it
> here? There can be any number of sequences.
That's exactly the issue: it needs to be structured so that callers can
usefully override it.
As it is currently defined, the only overriding possible is to provide
new valid values for the `type' argument.
So its default definition should make use of seq-into or something
similar so that new types can provide their own implementation.
E.g., you could define a new
(cl-defgeneric seq-into-sequence (seq)
(if (sequencep seq) seq
(error "Don't know how to turn %S into a sequence" seq)))
and then
(cl-defgeneric seq-concatenate (type &rest seqs)
(apply #'cl-concatenate type (mapcar #'seq-into-sequence seqs)))
Stefan