Skip to content

Conversation

@NthPortal
Copy link
Contributor

Addresses at least part of @SethTisue's concern in scala/collection-strawman#197.

@scala-jenkins scala-jenkins added this to the 2.13.0-M5 milestone May 8, 2018
@NthPortal NthPortal requested review from SethTisue and julienrf May 8, 2018 03:55
@NthPortal
Copy link
Contributor Author

I'm happy to add to this PR with more overridden methods; I'm just not sure exactly which methods are needed atm

@NthPortal NthPortal force-pushed the topic/lazylist-stack-safety/PR branch from 9613f0b to 9250f0c Compare May 8, 2018 12:49
object Test extends App {
// Should not overflow the stack
Iterator.iterate(LazyList.from(0))(_.dropWhile(_ => false)).drop(10000).next
Iterator.iterate( Stream.from(0))(_.dropWhile(_ => false)).drop(10000).next
Copy link
Contributor Author

@NthPortal NthPortal May 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't check for stack safety well enough - need to ensure that head and tail get evaluated (for both LazyList and Stream)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the actual problem Seth mentioned doesn't seem to manifest with LazyList anyway, it's good to check that it works

@NthPortal NthPortal force-pushed the topic/lazylist-stack-safety/PR branch from 9250f0c to 17f77f1 Compare May 9, 2018 00:32
@javax-swing
Copy link

@NthPortal I wonder if it's a valid test to check if a they use memory sharing.

val stream = Stream.of(1,2,3,4,5)
stream.drop(3) should be theSameInstanceAs stream.tail.tail.tail
val stream = Stream.of(1,2,3,4,5)
stream.dropWhile(_ <= 3) should be theSameInstanceAs stream.tail.tail.tail
val stream = LazyList.of(1,2,3,4,5)
stream.drop(3) should be theSameInstanceAs stream.tail.tail.tail
val stream = LazyList.of(1,2,3,4,5)
stream.dropWhile(_ <= 3) should be theSameInstanceAs stream.tail.tail.tail

@NthPortal
Copy link
Contributor Author

@javax-swing while they should do that, that feels to me like specifying an internal behaviour for no reason; maybe that's just me though

Override `dropWhile` in `LinearSeqOps`.

Remove redundant override for `dropWhile` in `List`.
@NthPortal NthPortal force-pushed the topic/lazylist-stack-safety/PR branch from 17f77f1 to 1bbef85 Compare May 10, 2018 04:24
@NthPortal
Copy link
Contributor Author

ping @SethTisue

@lrytz lrytz merged commit 596f047 into scala:2.13.x Jun 1, 2018
@lrytz
Copy link
Member

lrytz commented Jun 1, 2018

Thanks, @NthPortal!

@NthPortal NthPortal deleted the topic/lazylist-stack-safety/PR branch June 1, 2018 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants