I am writing a simple programming language. I see some programming languages use parentheses for the condition of an if
statement but some do not.
What are the advantages and disadvantages of using parentheses for the condition of an if
statement?
For example, in Rust, the if
statement looks like:
if number < 5 {
println!("condition was true");
}
What would this mean?
if a b
You can make this easier to parse and/or to comprehend by several methods:
if (a) b
if a { b }
if a then b
but you probably can't leave it as if a b
. The choice is a matter of taste and consistency with the rest of your programming language.