How about Seq.iterator returning BufferedIterator?

Hello,

How about changing the return type of Seq[A].iterator from Iterator[A] to BufferedIterator[A]?

I don’t know how Seq.iterator is typically implemented, but I’m assuming the most efficient way is to keep the Seq and an index, in which case it could be just as easily be a BufferedIterator.

Best, Oliver

Not every Seq is an IndexedSeq.

I see. Could then at least IndexedSeq.iterator return a BufferedIterator?

Since this is contributors.scala-lang.org and not users.scala-lang.org, I’m going to push back a bit: what upsides and downsides do you see? Did you spend some time thinking this through, and what did you come up with?

A change like this couldn’t be made until Scala 3.1 at the earliest; do you hope to push it through then? Would you like advice on how to try the change out in the scala/scala repo to see what goes wrong or doesn’t?

1 Like