Hacker News new | ask | show | jobs
by tekacs 3390 days ago
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.

1 comments

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.