Would anyone be opposed to...
A) Marking 'free' blocks (blocks not part of a
function/loop/if/alt/etc, but used solely for a new scope or to do
something before an expression) with a more explicit syntax.
This has the advantage of making them easier to spot and parse
(distinguishing '{ foo; bar; }' from '{mutable foo: bar}' as syntactic
elements isn't hard, but somewhat clunky) and resolving the obscure
ambiguity in 'if fail { blah }' (where {blah} could be an argument to
fail -- or put, or ret). Prefixing these blocks with some keyword
would make it more obvious that they are being used, introduce some
symmetry with other kinds of blocks, and solve these issues. Question
is, which keyword. I wanted to go with 'do' at first, but Brian
pointed out that this is in fact ambiguous. 'block'? 'begin'? 'run'?
Some ascii trick like '%{'?
B) Limiting implied-semicolons-after-blocks to blocks that end with a
trailing semicolon, requiring blocks in loops (where the value is
discarded anyway) to end in a trailing semicolon, and always treating
blocks that do end in semicolons as the end of the expression.
Right now, you can say 'while true { 1 }' and starting a line after a
trailing-block expression (say 'if x { a(); } else { b(); }') with a
'(' or a '[' will cause the parser to think you're trying to call or
index the result of the if expression.
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev