IF (n=to-from)<=1 THEN return FI
All modern languages that try and do a refresh on the C style (Rust and Swift notably) do this, it's clearly the right idea. They should just update the C and C++ syntax to make those parentheses optional at this point.(PS. some people would also recoil at the assignment-as-expression used in that line, but that's just good clean fun!)
if (a)
doThis();
andThat();
is interpreted as if(a){
doThis();
}
andThat();
Some compilers are nice enough to throw around misleading indentation warnings, but without an explicit block termination like FI this just causes issues all over the place.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.
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.
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!
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.
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.
In everyday usage in the UK, I’d wager that most refer to () as brackets, [] as square brackets and {} as curly brackets.
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.