-
Notifications
You must be signed in to change notification settings - Fork 18
add cycle
method to LazyList
#17
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
Conversation
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.
This does seem useful, though I don't like the fact that it requires you to construct a (it doesn't bother me that much)LazyList
instance that doesn't get used
src/test/scala/collection/immutable/TestLazyListExtensions.scala
Outdated
Show resolved
Hide resolved
src/test/scala/collection/immutable/TestLazyListExtensions.scala
Outdated
Show resolved
Hide resolved
@SethTisue do you mind if I push some changes? |
@NthPortal have at it UPDATE: but note that I just rebased |
6fc3f9d
to
d87d931
Compare
59e626c
to
86715e2
Compare
Luis (@BalmungSan) noticed that I forgot |
src/main/scala/scala/collection/immutable/LazyListExtensions.scala
Outdated
Show resolved
Hide resolved
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'm still thinking on this one. I think we might want it in a
next
sub-package? - I think it's quite valuable, and highly motivated given the links you provided.
- The states were
eq
but not theLazyList
s themselves; I've fixed the tests.
the Travis-CI .org to .com migration didn't happen smoothly here — separate ticket on that: #27 |
@NthPortal does the commit I just pushed line up with what you're proposing over at #24? |
yup |
@NthPortal additional commit pushed with more comments, more tests, more Scaladoc one thing I discovered is that (even for finite |
I don't know. I'm not sure what the cost of checking if it's a cycle is. The more I look at this, the more I think cyclic |
558758c
to
c89574a
Compare
meh, I'm fine with it as it stands |
sorry. I'll try to open a ticket or something. tomorrow. if I remember |
It depends on how deep one expects the support to go. For example, one might expect It's me who (iirc) got us both thinking about cycles in the first place, before 2.13.0 was released — and honestly I was bit surprised that you ran with it and added the cycle-checking code to |
@SethTisue - Actually, I think if we're going to support cycles at all, except as an accident, we should support them on |
if I understand what you're referring to, I didn't end up doing that I don't think (other than what was already there in |
I would love to, but I genuinely do not think it's possible without leaking a ton of memory and/or taking a huge performance hit, which is also undesirable. perhaps we could add cycle-aware variants of operations? I do think we should add documentation to the stdlib's docs (and have the docs for this point to that?) that most operations do not preserve cycles, and perhaps the few that do.
we have explicitly supported/handled cycles in |
@NthPortal re: the history on this, I trust your memory over mine
I don't want to work on that, and think we probably don't want to clutter
@Ichoran in practice, I don't think that's going to happen. I think our choices in practice are: add given that cycles are already "accidentally" supported, I feel like adding |
@NthPortal - Yes, I remember...I added the cycle-handling. It would be a lot of programmer effort but not, I think, all that computationally expensive to add it to most methods, as long as we don't guarantee zero unrolling of loops. (If we did, we'd have to represent them explicitly.) If we instead guarantee at most one unroll of a loop, we'd spend at most 1/2 an extra traversal on non-cyclic I guess the real question about cycles with things like Nonetheless, we should keep our eyes open for which methods might benefit from cycle handling in a non-problematic way. |
added to Scaladoc: + *
+ * Note that some `LazyList` methods preserve cyclicality and others do not.
+ * So for example the `tail` of a cycle is still a cycle, but `map` and `filter`
+ * on a cycle do not return cycles. I think I'm now satisfied with this. |
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.
looks pretty good to me; I think it needs just a few (mostly cosmetic) changes
src/test/scala/scala/collection/immutable/TestLazyListExtensions.scala
Outdated
Show resolved
Hide resolved
src/test/scala/scala/collection/immutable/TestLazyListExtensions.scala
Outdated
Show resolved
Hide resolved
src/test/scala/scala/collection/immutable/TestLazyListExtensions.scala
Outdated
Show resolved
Hide resolved
review feedback, handled. also: squashed, rebased. |
2fb9fcf
to
1348e32
Compare
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.
LGTM! ty Seth!
not for merge yet... ...since I'm not sure yet if we have sufficient consensus yet on actually adding this — I don't really know who watches this repo and who doesn't. so let's hold off on merging — I think we'll need to institute some (not-TOO-overly-formal) process for that involving signoff from both the Scala 2 team at Lightbend and the Scala 3 team at EPFL |
Well this has now been sitting in limbo for a whole year since no one (including me) has stepped forward to formulate an approval process. I'm going to close it to get it out of my personal PR list. We can find it again with the "status:pending" label. |
I'm looking for multiple kinds of review here:
testConstantMemory1
fail? @NthPortal is this as-expected?if folks agree this should be added, I can do a better job on the Scaladoc