mozilla/rust — Issue #1712: Expression syntax and semicolon
Author: oipn4e2
Created: 2012-01-31 01:13:16+00:00
State: open

Hi, I'm a Rust language newbie so what I mention below may be non-sense. :-)

I think it is not that wise to make use of semicolon (;) as the separator between statements along with the expression syntax provided in the language, because it will potentially lead to many typo-caused bugs. For example, for the following snippet from the [Rust language tutorial](http://doc.rust-lang.org/doc/tutorial.html#expression-syntax):

```rust
let x = if the_stars_align() { 4 }
else if something_else() { 3 }
else { 0 };
```

If the expressions inside the braces are function calls, it would be harder to decide:

```rust
let x = if the_stars_align() { my_pretty_print_function(123) }
else if something_else() { your_pretty_print_function(456) }
else { out_error_print_function(789) };
```

and

```rust
let x = if the_stars_align() { my_pretty_print_function(123); }
else if something_else() { your_pretty_print_function(456); }
else { out_error_print_function(789); };
```