scala / collection-strawman

Implementation of the new Scala 2.13 Collections
Apache License 2.0
200 stars 72 forks source link

Make toString in LazyList consistent with other collections. #512

Closed julienrf closed 6 years ago

julienrf commented 6 years ago

Fixes scala/collection-strawman#376 Fixes scala/collection-strawman#420

This is a rebased and squashed version of #446 (authored by @dhanesharole).

szeiger commented 6 years ago

Oh, I just wondered why my commit showed up in this branch but it doesn't. We both did the same change (https://github.com/scala/collection-strawman/commit/ec281081cb0cd8753ba8a6b1efa1cb29fc29a5b3)

julienrf commented 6 years ago

Oops, I pushed --force

szeiger commented 6 years ago

We could even consider making this the default implementation of mkString in IterableOps and overriding it with the current default implementation in StrictOptimizedIterableOps. This would be more consistent with other default implementations where the lazy version is in IterableOps

julienrf commented 6 years ago

We could maybe do it in SeqOps or LinearSeqOps (because it relies on head and tail). But I think that’s out of the scope of this PR.

szeiger commented 6 years ago

Right, you'd need at least a LinearSeq for proper head/tail destructuring. Iterators couldn't express the headDefined/tailDefined semantics.