Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple2.zipped not lazy enough for Streams #2634

Closed
scabug opened this issue Nov 14, 2009 · 4 comments
Closed

Tuple2.zipped not lazy enough for Streams #2634

scabug opened this issue Nov 14, 2009 · 4 comments
Assignees

Comments

@scabug
Copy link

scabug commented Nov 14, 2009

Welcome to Scala version 2.8.0.Beta1-RC1 (Java HotSpot(TM) Client VM, Java 1.6.0_11).
Type in expressions to have them evaluated.
Type :help for more information.

scala> val fib: Stream[Int] = 1 #:: 1 #:: fib.zip(fib.tail).map { case (a,b) => a + b }
fib: Stream[Int] = Stream(1, ?)

scala> fib take 10 toList
res1: List[Int] = List(1, 1, 2, 3, 5, 8, 13, 21, 34, 55)

scala> val fib: Stream[Int] = 1 #:: 1 #:: (fib, fib.tail).zipped.map(_ + _)
fib: Stream[Int] = Stream(1, ?)

scala> fib take 10 toList
java.lang.StackOverflowError
        at scala.collection.mutable.LazyBuilder.<init>(LazyBuilder.scala:23)
        at scala.collection.immutable.Stream$$StreamBuilder.<init>(Stream.scala:427)
        at scala.collection.immutable.Stream$$.newBuilder(Stream.scala:418)
        at scala.collection.generic.GenericTraversableTemplate$$class.genericBuilder(GenericTraversableTemplate.scala:34)
        at scala.collection.immutable.Stream.genericBuilder(Stream.scala:41)
        at scala.collection.generic.TraversableFactory$$GenericCanBuildFrom.apply(TraversableFactory.scala:22)
        at scala.collection.generic.TraversableFactory$$GenericCanBuildFrom.apply(TraversableFactory.scala:21)
        at scala.Tuple2$$Zipped.map(Tuple2.scala:54)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:489)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:483)
        at scala.collection.LinearSeqLike$$$$anon$$1.next(LinearSeqLike.scala:72)
        at scala.Tuple2$$Zipped$$$$anonfun$$map$$1.apply(Tuple2.scala:59)
        at scala.collection.immutable.Stream.foreach(Stream.scala:191)
        at scala.Tuple2$$Zipped.map(Tuple2.scala:57)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:489)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:483)
        at scala.collection.LinearSeqLike$$$$anon$$1.next(LinearSeqLike.scala:72)
        at scala.Tuple2$$Zipped$$$$anonfun$$map$$1.apply(Tuple2.scala:59)
        at scala.collection.immutable.Stream.foreach(Stream.scala:191)
        at scala.Tuple2$$Zipped.map(Tuple2.scala:57)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:489)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:483)
        at scala.collection.LinearSeqLike$$$$anon$$1.next(LinearSeqLike.scala:72)
        at scala.Tuple2$$Zipped$$$$anonfun$$map$$1.apply(Tuple2.scala:59)
        at scala.collection.immutable.Stream.foreach(Stream.scala:191)
        at scala.Tuple2$$Zipped.map(Tuple2.scala:57)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at $$anonfun$$1$$$$anonfun$$apply$$1.apply(<console>:4)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:489)
        at scala.collection.immutable.Stream$$Cons.tail(Stream.scala:483)
        at scala.collection.LinearSeqLike$$$$anon$$1.next(Linea...
@scabug
Copy link
Author

scabug commented Nov 14, 2009

Imported From: https://issues.scala-lang.org/browse/SI-2634?orig=1
Reporter: @szeiger

@scabug
Copy link
Author

scabug commented Nov 24, 2009

@adriaanm said:
Sorry, we'll have to spec zipped as returning a strict collection, because the lazy variant is too complicated to implement with the current interface for Builder. Or are we missing something? Will be a wontfix as soon as I get a chance to update the documentation to reflect this.

@scabug
Copy link
Author

scabug commented Feb 26, 2010

@adriaanm said:
(In r20998) see #2634: updated docs to indicate zipped is strict

@SethTisue
Copy link
Member

wontfix until 2.13, then willfix? design discussion at scala/collection-strawman#223

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants