On 7/24/13 7:59 PM, Jeaye wrote:
We had some discussion recently about reforming the for-loop syntax
since we'll be switching it to external iterators and it's a bit
deceptive to the user to be writing a lambda-pattern there.
Have we yet considered C++11's approach to this?

     for <name> : <expr> { ... }

This seems pretty consistent to me at first glance, considering how we
use a similar syntax to declare and initialize fields. Consider <name>
being initialized by <expr> for each value in <expr>.

I'd like to reserve `:` as the type ascription operator (thanks to Michael Artzenius for the name): i.e. assertion that some pattern or expression has a given type. This would eliminate a bunch of `let` bindings that are currently sometimes used when the type inference fails.

For example, you could write:

    debug!("%?", from_json("{ \"foobie\": \"bletch\" }") : MyObject)

Instead of:

    let my_object: MyObject = from_json("{ \"foobie\": \"bletch\" }");
    debug!("%?", my_object);

Anyway, that would conflict with this.

Patrick

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

Reply via email to