On 12/06/13 15:58, Niko Matsakis wrote:
I think this is great. It is a more intuitive rewriting than the current for-loop (where it is not even obvious whether for-loops could be rewritten without compiler magic).I imagine that `for <expr> |<pat>| { <body> }` would be syntactic sugar for:let mut _iterator_ = <expr>; loop { let <pat> = match _iterator_.next() { None => break, Some(v) => v }; <body> }
Arguably retaining the current `for` syntax suggests closures where none exist, but it seems silly to change it and invalidate all existing programs for this reason (I imagine `for <pat> in <expr>` would be the more standard syntax).
I don't feel strongly but I think I would prefer `for <pat> in <expr> { ... }` because it looks different to a closure and also because it gets rid of two |. My rust code breaks every time I get the latest incoming anyway - and it is a pretty mechanical change.
Gareth _______________________________________________ Rust-dev mailing list [email protected] https://mail.mozilla.org/listinfo/rust-dev
