I have a few ideas that I've been tossing around that may fix some of
these issues:
(1) ML-style expression |if|. So |if| as an expression would be written
|if cond then expr else expr|, while statement-if would remain the same.
The expressions aren't braced and the first is preceded by |then|, which
avoids the ambiguity between expression-if and statement-if.
CoffeeScript uses the same trick to disambiguate between the two forms.
This could replace the ternary as well.
(2) Remove expression-while, expression-do-while and expression-for;
make them statements. These don't have useful completion values, except
for maybe expression-do-while... but that is a rare construct.
The above two points should eliminate the "statement-that-ends-in-}
precedes index or call op" ambiguity. It also makes |while (true) { 1 }|
no longer allowed.
(3) Ignore trailing semicolons, just as in OCaml. In other words, the
final expression of a block may be followed by a ';'. This avoids a
common hazard (the fact that ';' changes the return value) which
newcomers to Rust tend to stumble over.
(4) Make |ret| a statement, avoiding the "if ret { ... }" ambiguity.
(5) Make |fail| a function in the standard library, or at least require
mandatory parentheses around its argument.
The above two mini-proposals should eliminate the "if
expr-that-takes-an-optional-operand {" ambiguity.
Thoughts?
Patrick
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev