by marcoms · 9y ago · 0 comments
--
As a side point, I hope switch statements are less like C and more like Rust (Rust happens to have better looking syntax, not just because its Rust):
match <identifier> {
<val> => {
//
}
..
}
C-style always creates confusion on how to indent blocks following case statements if foo*bar baz()
...being parseable as either of these: if (foo) { *bar } baz()
if (foo*bar) { baz() }
That example can be solved with enough lookahead but I think I found cases where it couldn't be (although I can't bring them to mind). Terminator tokens are another way to solve it, so you get Ada-style: if foo*bar then baz() endif
...or Go-style: if foo*bar { baz() } if foo
*bar
baz()
if foo*bar
baz()And even if you make newlines meaningful you only trade one pain for another, namely, you now need some kind of line continuation construct and lots of special cases where newlines are allowed...
In short: it's not that simple.
What the GP poster was talking about was parentheses around the /conditions/ of an if statement.
Note that Rust (for example) doesn't require the latter.
In fact, if you always require braces (as in the post that you linked), then it's very easy to parse and read code which is lacking those parentheses on the condition.
i.e. `if (condition) x = x + 1` would be hard to read without parens. but `if condition { x = x + 1 }` (with mandatory braces) is quite clear.
Given the context, I'm pretty sure the OP was using the 'parenthesis' meaning.