GroupedIterator

23 views
Skip to first unread message

Michel Charpentier

unread,
Aug 24, 2016, 9:42:56 AM8/24/16
to scala-user
Two quick questions regarding `GroupedIterator`:

1) Although `GroupedIterator` has type `Iterator[Seq[A]]`, the signature of its `next` method returns a `List[A]`.  Is it safe to rely on this behavior or could that change without notice?

2) Classes like `GroupedIterator` are defined to `extend AbstractIterator[A] with Iterator[A]`.  What's the point of `with Iterator[A]`?  Wouldn't the class be the same without it?

MC

Seth Tisue

unread,
Aug 29, 2016, 6:55:55 PM8/29/16
to scala-user
On Wednesday, August 24, 2016 at 6:42:56 AM UTC-7, Michel Charpentier wrote:
Two quick questions regarding `GroupedIterator`:

1) Although `GroupedIterator` has type `Iterator[Seq[A]]`, the signature of its `next` method returns a `List[A]`.  Is it safe to rely on this behavior or could that change without notice?

It can't be changed without breaking both source and binary compatibility, so you know it can't change until the next Scala major version (2.11=>2.12=>2.13...). But it seems like a bad thing to have baked into the API, so I imagine a pull requesting giving it a more abstract type in 2.13 would be accepted.
 
2) Classes like `GroupedIterator` are defined to `extend AbstractIterator[A] with Iterator[A]`.  What's the point of `with Iterator[A]`?  Wouldn't the class be the same without it?

It was added in commit 106180d. I don't understand why; it appears to me the addition makes no difference.

Seth Tisue / Scala team / Lightbend, Inc. 
Reply all
Reply to author
Forward
0 new messages