]> git.lizzy.rs Git - rust.git/commit
auto merge of #8141 : graydon/rust/foreach-in-sketch, r=brson
authorbors <bors@rust-lang.org>
Wed, 31 Jul 2013 10:58:21 +0000 (03:58 -0700)
committerbors <bors@rust-lang.org>
Wed, 31 Jul 2013 10:58:21 +0000 (03:58 -0700)
commit6296dc0d73527301f18ef55b5f2d07c3241b8a00
tree9ca1c483e62e852fb33db8aee766ba4c7e798eb9
parent8b7e241e02bb9f82d7b931033afde477d03ff4f2
parenta696f0fecb9d11204f64d310eb66e095f64bd04a
auto merge of #8141 : graydon/rust/foreach-in-sketch, r=brson

This is a preliminary implementation of `for ... in ... { ...}` using a transitionary keyword `foreach`. Codesize seems to be a little bit down (10% or less non-opt) and otherwise it seems quite trivial to rewrite lambda-based loops to use it. Once we've rewritten the codebase away from lambda-based `for` we can retarget that word at the same production, snapshot, rewrite the keywords in one go, and expire `foreach`.

Feedback welcome. It's a desugaring-based approach which is arguably something we should have been doing for other constructs before. I apologize both for the laziness associated with doing it this way and with any sense that I'm bending rules I put in place previously concerning "never doing desugarings". I put the expansion in `expand.rs` and would be amenable to the argument that the code there needs better factoring / more helpers / to move to a submodule or helper function. It does seem to work at this point, though, and I gather we'd like to get the shift done relatively quickly.