Braceless body in semicolon languages is bad design
What Rust and Go do here is better, for two reasons:
- The braceless body is a mistake hazard. It's common that you write an if statement with a one-line body and then later add a second line to the body; if you didn't include the braces before, it's easy to forget to add them now and get a bug. I've met people who insist that you should always include braces anyway for this reason.
- Parentheses around conditions that themselves end with parentheses result in stacks of parentheses that are hard to read.
subscribe via RSS