As agreed on in this week's meething, I removed compiler support for
iter functions and for-each loops today. Instead, it is now possible
to say

    uint::range(0u, 10u) {|i|
        log_err i;
    }
    my_map.items {|key, val|
        ...
    }

If an call expression in statement position is followed directly by a
block ({| or {||), that block is added as a final argument to the
call. For a non-call expression, the expression becomes a call with a
single argument, the block.

(The reason it only recognizes expressions in statement position---at
the top level of an outer block---is that this way, you don't need to
terminate a block call with a semicolon. When using higher-order
functions in a way that returns a value, you'll have to put the block
inside the parentheses as before.)

Iterators are now simply functions that take a block as their last
argument. They are strictly as powerful as our old iterators, and
require much less compiler machinery.

An open problem is whether we want to allow break/continue or even
returning from the outer function inside a block. (This didn't work
for the old iterators either.)

Best,
Marijn
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to