On 08/10/2013 07:24 PM, Paul Nathan wrote:
On 8/10/13 7:10 AM, Simon Sapin wrote:
Hi,

Now that the for loop is based on external iterators, can we reconsider
"for-else"?

Proposal:

     for i in iter {
         // ...
     } else {
         // ...
     }

The optional else block is executed when the for loop stops without
exhausting the iterator, ie. when "break" is used.

I spent quite some time in Python, delving into as much of the language
as I could, and for-else was not something I used. It actually caused me
a bug due to a mis-indented if block in the for loop.

I would suggest that perhaps for-else belongs as a macro construct for a
while to test adoption; if it proves useful and strongly adhered to, it
could be moved into the core language?
+1 for a macro approach.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to