* Jürg Billeter wrote, On 17/12/08 13:51:
On Wed, 2008-12-17 at 13:39 +0000, Sam Liddicott wrote:* Jürg Billeter wrote, On 17/12/08 13:04:foreach is meant to be used for read-only iteration over a collection as this is very common. It's really just a bit syntactic sugar. If you need more features, use a while loop with an appropriate iterator. I read that as applying to arrays, and not to anything implementing the iterable interface, my mistake Precisely that....Thinking back to my dylan days (anyone ever use dylan?) it was common to have modifiable iterators. I'm suggesting that foreach could also be used on objects that support an iterable interface, so that a function could return an iterator that is used by foreach and destroyed after the for-each. Thus the syntactic sugar could remain but also support modifying the collection if the collection could produce a safe iterator.I don't quite understand, foreach works on objects that implement the iterable interface. What exactly are you proposing? I also mis-read Phil's response and also the original question from Кутейников Дмитрий. And I've not been well lately.... :-) Sam |