Feedback and comments on ARM proposal (original) (raw)
Marek Kozieł develop4lasu at gmail.com
Sat Mar 14 19🔞28 PDT 2009
- Previous message: Feedback and comments on ARM proposal
- Next message: Feedback and comments on ARM proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
2009/3/10 Joshua Bloch <jjb at google.com>
Roel, There were several reasons. The main reason was that we wanted the for-each loop to be side-effect free. Had we allowed Iterators, two consecutive for-each statements on the same Iterator would have been legal, but would have had very different semantics from two consecutive for-each statements over the same Iterable. The former would have traversed the collection once, while the latter traversed it twice. We thought this might lead to bugs. Also it allowed us to avoid the issue of what to do if the object to be iterated over implemented both Iterable and Iterator. There were people on the expert group who argued to allow Iterator, but in the end it was decided we decided that it was best not to support it.
Regards, Josh
Thanks.
When you give the reason it's much easier to find some logic answer.
After some thoughts: We could introduce while-each loop ;) just for iterators, while now I agree with you that for-each loop should be iterator free.
Is that my imagination or now time the problem are proportions in comfort and complexity in language?
-- Pozdrowionka. / Regards. Lasu aka Marek Kozieł
http://lasu2string.blogspot.com/
- Previous message: Feedback and comments on ARM proposal
- Next message: Feedback and comments on ARM proposal
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]