On 9/14/11 11:10 AM, Patrick Walton wrote:
Fair enough; if others don't like separate expression and statement
forms, I'd vote for |val| for block-expression, without the |res| (it's
an interesting idea, but I'm not sure it's necessary -- maybe something
to think about for future versions?) I suspect |val| will be rare.
Come to think of it, this actually solves an ugliness in C++: the
"artificial block" pattern used when you want to run a destructor at
some specified time. You see stuff like this in C++:
...
{
auto_ptr<some_big_data_structure> ptr =
make_big_data_structure();
cout << ptr.to_string();
// I want the pointer immediately destroyed here
}
...
But the artificial blocks look pretty ugly. With |val| (or |do|) we
could make it nicer:
...
do {
let ptr = ~make_big_data_structure();
log ptr;
// I want the pointer immediately destroyed here
}
...
Patrick
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev