[rust-dev] Brace-free if and alt

Patrick Walton pwalton at mozilla.com
Wed Apr 11 13:54:37 PDT 2012

On 4/11/12 1:52 PM, Benjamin Striegel wrote:
> Really not a fan of the alternative `if` syntax, and I think that the
> problem of "too many braces" applies primarily to `alt` expressions
> anyway. Another reason to be wary of your `if` proposal is that it makes
> Rust's already-a-little-scary semicolon rules a bit harder to express
> ("you don't need a semicolon after a closing brace in a control flow
> expression statement that is not a component of a larger statement" is
> already about at the threshold of credulity without adding "...or
> immediately after an `if` statement making use of the alternative syntax").
> An alternative `alt` syntax could be cool. One thing that I like about
> the current syntax with the required braces is that it flows nicely from
> the understanding "this is the end of a block, therefore this is where
> the implicit `ret` exists", which is handy enough that it helps get over
> the initial anxiety of semicolon significance. What if your alternative
> syntax used a colon rather than a fat arrow, to mirror record literal
> syntax?

Requires unbounded lookahead due to type annotations in patterns also 
using ":".


More information about the Rust-dev mailing list