Why do many languages use parentheses around `if` condition -


many programming languages require parentheses around if condition.

for example:

if (x < 50) { } 

why can't written this, without parentheses:

if x < 50 { } 

assuming language designers pragmatic people, why parentheses required?

in c, if takes comma-operator, instead of expression. 1 can write:

int = 0; if (i = + 1, i/2 > 0) { } 

so need braces (parenthesis actually) here. same true while() example.

return operator in c accepts expression, not require parenthesis:

return + 1; 

though many programmers still write like:

return (i + 1); 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -