On 6/7/12 2:20 PM, Gareth Smith wrote:
I think that allowing an early exit with a break/continue from lambdas
that use this special form is confusing, because "breaking" may or
may-not actually resume the code that follows the do-call. The lambda
might be put into a data structure for later execution, or, like in your
spawn example, executed in a new task.

I would prefer that instead of having a special `do` form, all `|| expr`
lambdas could have early returns using `ret`.

If you allow all block lambdas to have early returns with "ret", then this:

    fn f() {
        for int::range(1, 10) |i| {
            ret i;
        }
    }

Has a very different meaning from:

    fn f() {
        int::range(1, 10) |i| {
            ret i;
        }
    }

IMHO this is likely to be pretty confusing.

Also, eliminating "do" makes this ambiguous:

    spawn() || {
        ...
    }

Is ambiguous with bitwise-or. This is also ambiguous:

    spawn || {
        ...
    }

In any case, I think this looks nicer:

    do spawn {
        ...
    }

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

Reply via email to