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
Increase laziness of LazyList.cons.apply #9095
Conversation
@@ -693,6 +693,20 @@ class LazyListLazinessTest { | |||
assertLazyAllSkipping(op, 4) | |||
} | |||
|
|||
private def genericCons_unapply_properlyLazy(unapply: LazyList[Int] => Option[(Int, LazyList[Int])]): Unit = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed there were no tests for these while I was in the area, so I added tests
Port of scala/scala#9095. Co-authored-by: NthPortal <nthportal@gmail.com>
Port of scala/scala#9095. Co-authored-by: NthPortal <nthportal@gmail.com>
Port of scala/scala#9095. Co-authored-by: NthPortal <nthportal@gmail.com>
Port of scala/scala#9095. Co-authored-by: NthPortal <nthportal@gmail.com>
Port of scala/scala#9095. Co-authored-by: NthPortal <nthportal@gmail.com>
@NthPortal would you mind improving the PR title and description to be at least a little more informative for end users? since we're linking to this from the 2.13.4 release notes perhaps you can borrow some verbiage from the discussion on #8985 |
@SethTisue is that okay? |
@NthPortal better — if you want to improve it further, I would suggest adding an example code snippet that is affected by the change, and describe how it is affected. even though I've looked at this stuff multiple times before, when I see |
"If you're as lazy as LazyList, you probably don't need to know more." Sometimes it helps to be usefully vague. Do I need to learn this?
|
Change
LazyList.cons.apply
so that the tail computationis wrapped as a state computation for a new
LazyList
,thus deferring its execution as long as possible.
Follow-up to #8985
Before (Scala 2.13.3-):
After (Scala 2.13.4+):