Re:Philosophy and "for" loops — more from Go and Rust
by chrismorgan on Thursday July 11, 2013 @11:50AM
(#6026806)
Well, in 0.7 the external iterator `each` pattern is mostly gone, leaving external iterators the standard style, but because the semantics of `for` haven't changed yet, there is an `advance` method provided for iterators, such that the code is actually at present thus:
[ Parent
| on HN ]
Re:Philosophy and "for" loops — more from Go and Rust
by kibwen on Thursday July 11, 2013 @12:11PM
(#6026958)
Right, I was hoping we could avoid mentioning this brief and ugly interlude in our evolution. :)
Re:Philosophy and "for" loops — more from Go and Rust
by bjz_ on Thursday July 11, 2013 @05:53PM
(#6029498)
It's been a courageous effort by strcat, pushing such ugliness on us over the 0.7 milestone, but it will certainly pay off into the future. I look forward to the new sugar!
Re:Philosophy and "for" loops — more from Go and Rust
by anonymous on Thursday July 11, 2013 @01:11PM
(#6027404)
That is basically a while loop without a "proper body", right? At each iteration advance is called with the closure as first argument and iteration continues until it returns false?
Re:Philosophy and "for" loops — more from Go and Rust
by kibwen on Thursday July 11, 2013 @02:24PM
(#6028038)
You're correct. You can see as much here in the implementation of `advance` (as you'd expect, it's very simple):
https://github.com/mozilla/rust/blob/master/src/libstd/itera...