Provide a asSeq facade for Chunk
BalmungSan opened this issue · 1 comments
Sometimes when interoperating all you want is to be able to pass a Chunk
to a method that expects a Seq
without having to actually copy data. The main argument is that such a method will iterate the sequence once to produce something else.
On top of this, it may also be good to provide an asJava
facade as well, returning ju.List
.
Technically speaking, asSeq
would allow us to also call the asJava
the stdlib already provides, but that would be a facade over a facade; not the end of the world but it may be a good tiny optimization.
It would be really nice to have such a method. However, my concern is that the Seq
interface is supposed to be backed by some concrete collection. For example, it provides iterableFactory
, which defaults to one from the object Seq
. Also, there are a bunch of methods in Seq
that use that factory for internal purposes (e.g. append
, prependAll
, etc). Therefore I doubt it is really feasible to be always non-copy with Seq
.
The better bet could be SeqView
(or even better IndexedSeqView
), which is nothing but Seq
without a factory per se.
But IIRC it only shows up in Scala 2.13, unfortunately.