5 ms·
he meant making the (a) part optional to make "if a" instead. parenthesis are (), {} are braces :)
by skocznymroczny 5y ago
he meant making the (a) part optional to make "if a" instead. parenthesis are (), {} are braces :)
- josefx 5y agoOne of the few times I get to remember that English is only my second language. Can't really think of a reason for not dropping them unless there is a weird corner case in the existing grammar.
- thaumasiotes 5y ago> One of the few times I get to remember that English is only my second language. Most native speakers aren't aware of the terms. They'll call anything by any name. There is a significant constituency for "curly brackets {}" and "square brackets []". Anyway, there are mistakes you could make that would give you away as a nonnative speaker, but that wasn't one of them.
- dragonwriter 5y ago> There is a significant constituency for "curly brackets {}" and "square brackets []". Yes, but there is still basically no constituency for “parentheses” (“{}”) or “parentheses” (“[]”), except in some narrow specific contexts; in programming, one example would be discussion of certain Lisp dialects where either all or certain uses of “()” in classic Lisp can (or, in the “certain” case, sometimes must) use the others, in which context “parentheses” are sometimes used generically for all three. So, while there is a variety of ways paired delimiters are described by native speakers, the particular use here was still outside of the normal range of that variation.
- iainmerrick 5y agoIf you dropped the parentheses around the condition, I think you’d have to make the braces around the body mandatory. Many (most?) C style guides make the braces mandatory, but it’d be a big step to actually change the language syntax that way. Tons of existing code would need to be updated. .. although I guess that could be automated!
- OskarS 5y agoYou could probably do an either or thing: "You can drop the parentheses if you use braces. But you can't drop both". Though you're right, this is why it'll never happen. Basically, C had a choice of eliding the parentheses around the condition or the braces around a single-statement block, and they chose the braces. With a half-century of hindsight, that was probably the wrong choice.
- iainmerrick 5y agoInteresting, either/or could work! That's a nice idea. Syntactically it seems unambiguous because after an 'if' you just need to check for an '(', and if you don't find it you're looking for a '{' after an expression. You'd lose forward compatibility, but I think there's precedent for that in C language revisions.
- jen20 5y agoThe GP is only correct in America, and only in formal usage. In everyday usage in the UK, I’d wager that most refer to () as brackets, [] as square brackets and {} as curly brackets.
- wheybags 5y agoIn everyday use, by non programmers, they're all just brackets.
- jen20 5y agoGood point - I should have said "everyday use among programmers". I don't imagine people regularly encounter braces or square brackets if not working in code.
- dllthomas 5y agoI never realized this. Does "parenthetical" still have the same meaning?
- camtarn 5y agoYep. Fun fact: parenthesis / parenthetical can mean 'a word or phrase inserted as an explanation or afterthought into a passage which is grammatically complete without it, in writing usually marked off by brackets, dashes, or commas.' (Merriam-Webster) - so you can have a parenthetical statement without using actual parentheses.
- drekipus 5y agowould that count?
- deleted 5y ago[deleted]
- cxr 5y agoThis is not relevant to the actual context of the remark that was written. The mistake being corrected is the misreading of the word "parentheses", believing it to refer to `{` and `}`. Even in the UK, that conclusion is wrong. So the GP you refer to as "only correct in America" is simply "correct", period (full stop).