[rust-dev] Proposal: Java-style iterators

2011-09-28 Thread Patrick Walton
It would be nice if we could figure out what to do about iterators for 0.1. I was thinking that we could make them Java-style iterators -- that is, objects with has_next() : bool and next() : T methods. |for each| would simply be syntactic sugar. This form: for each (x in iter()) {

Re: [rust-dev] Proposal: Java-style iterators

2011-09-28 Thread Brendan Eich
On principle I do not want us to go down this path, even if we change later. It adds risk that we won't change. It imposes a stateful model on iterators where has_next and next must be coherent, and you have to write two methos (not one as in Python or JS.next). And, Java. /be On Sep 28,

Re: [rust-dev] Proposal: Java-style iterators

2011-09-28 Thread Patrick Walton
On 9/28/11 5:27 PM, Brendan Eich wrote: On principle I do not want us to go down this path, even if we change later. It adds risk that we won't change. It imposes a stateful model on iterators where has_next and next must be coherent, and you have to write two methos (not one as in Python or

Re: [rust-dev] Proposal: Java-style iterators

2011-09-28 Thread Brendan Eich
On Sep 28, 2011, at 5:53 PM, Patrick Walton wrote: On 9/28/11 5:27 PM, Brendan Eich wrote: On principle I do not want us to go down this path, even if we change later. It adds risk that we won't change. It imposes a stateful model on iterators where has_next and next must be coherent, and

Re: [rust-dev] Proposal: Java-style iterators

2011-09-28 Thread Rob Arnold
+1 This is nice. Should make iterating over ML-style lists very natural. Not sure how you would write a closure for an array, could you post a sample for that? -Rob On Wed, Sep 28, 2011 at 5:54 PM, Brendan Eich bren...@mozilla.org wrote: On Sep 28, 2011, at 5:53 PM, Patrick Walton wrote: On