Issue #6142 has been reported by Innokenty Mikhailov. ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142 Author: Innokenty Mikhailov Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
on 2012-03-14 10:25
on 2012-03-14 14:32
Issue #6142 has been updated by Thomas Sawyer. A touch OT, but is Brian Candler being involved in the development of this? I don't know of anyone who has discussed and worked on this topic more over the years than Brian and I think it would be most prudent to seek his consul on these matters. (Not to speak for Brain, of course, but just saying.) ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142#change-24578 Author: Innokenty Mikhailov Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
on 2012-03-16 04:04
Issue #6142 has been updated by Shugo Maeda. File lazy_zip_to_a.diff added Innokenty Mikhailov wrote: > a = (1..3).lazy.zip('a'..'z') > a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] > a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] > > I believe that is not the desired behavior here and a.to_a should always return the same value. I agree that the current behavior is confusing, and the attached patch fixes it in the above case, but the patch cannot fix it in the following case: a = (1..3).lazy.zip('a'..'z').map {|i| i.join(":")} p a.to_a #=> ["1:a", "2:b", "3:c"] p a.to_a #=> ["1:d", "2:e", "3:f"] It may be difficult to fix it without performance decrease. We have three options: (1) Keep the current behavior. (2) Rewind enumerators only when to_a is directly invoked on the lazy enumerator returned by lazy.zip. (3) Rewind enumerators even if to_a is invoked on a chained enumerator. This may cause performance decrease. ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142#change-24623 Author: Innokenty Mikhailov Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
on 2012-03-16 04:07
Issue #6142 has been updated by Shugo Maeda. Thomas Sawyer wrote: > A touch OT, but is Brian Candler being involved in the development of this? I don't know of anyone who has discussed and worked on this topic more over the years than Brian and I think it would be most prudent to seek his consul on these matters. Any comments from Brian and others are welcome. If there is something wrong with the current behavior, please file a ticket or send a mail to ruby-core. ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142#change-24624 Author: Innokenty Mikhailov Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
on 2012-03-23 10:44
Issue #6142 has been updated by shugo (Shugo Maeda). Status changed from Open to Feedback Assignee set to shugo (Shugo Maeda) ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142#change-25068 Author: gregolsen (Innokenty Mikhailov) Status: Feedback Priority: Normal Assignee: shugo (Shugo Maeda) Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
on 2013-01-19 02:42
Issue #6142 has been updated by shugo (Shugo Maeda). Status changed from Feedback to Closed This issue should be discussed in #7691 and #7696. ---------------------------------------- Bug #6142: Enumerable::Lazy#zip doesn't rewind internal enumerators https://bugs.ruby-lang.org/issues/6142#change-35482 Author: gregolsen (Innokenty Mikhailov) Status: Closed Priority: Normal Assignee: shugo (Shugo Maeda) Category: Target version: ruby -v: ruby 2.0.0dev (2012-03-14 trunk 35013) [x86_64-linux] All enumerables passed to Enumerable::Lazy#zip are converted into lazy enumerators. When result evaluated - ruby iterates over this enumerators while calling #next to retrieve the next value. But those enumerators are not rewinded: a = (1..3).lazy.zip('a'..'z') a.to_a #=> [[1, "a"], [2, "b"], [3, "c"]] a.to_a #=> [[1, "d"], [2, "e"], [3, "f"]] I believe that is not the desired behavior here and a.to_a should always return the same value.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.