Hacker News new | past | comments | ask | show | jobs | submit login

If 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!




You 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.


Interesting, 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.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: