Hacker News new | ask | show | jobs
by yarrel 3394 days ago
The argument (which I agree with, although it can be a pain to adopt at first):

http://wiki.c2.com/?AlwaysUseBracesOnIfThen

2 comments

What you linked is about braces around the /body/ of an if statement.

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.

The GP said brackets, not parens. Perhaps he misspoke?
Ah, yeah. I didn't twig until you mentioned it, but... if ever you get tired of emacs vs vi religious wars, try switching to discussing whether 'bracket' refers to a parenthesis or a brace.

Given the context, I'm pretty sure the OP was using the 'parenthesis' meaning.

in commonwealth english, it's most commonly "brackets" for (), "square brackets" for [] and "curly brackets" for {}
Yeah, that's what I grew up with.

Where is it otherwise? Is bracket={} a USism? I've never been sufficiently aware to isolate the demographic.

In British English, 'brackets' means parentheses, as opposed to square brackets or curly brackets (also called braces). Maybe OP uses British English.
I'm also British, which may explain why I was able to read the GP's post first time.
Ah, I never knew. Thanks for the information.
As others speculated I meant parentheses around the condition - my mistake, I should have qualified