9.3 braces are acceptable in two of the three main braces placement rules. The first is the best: place braces in the same column below the keyword: if (condition ){... while (condition ){...}} the traditional UNIX bracket rule is: SyntaxHighli
9.3 braces
Two of the three main braces are acceptable, and the first is the best:
Place braces in the same column below the keywords:
If (condition)
{
...
While (condition)
{
...
}
}
The traditional brackets of UNIX are the same as the keywords, and the ending brackets are the same as the keywords:
If (condition ){
...
While (condition ){
...
}
}
Non-principled issues that have aroused heated debate can be solved through a compromise. either of the two methods is acceptable, but most people prefer the first one. The reason is the scope of psychological research.
There are more reasons to prefer the first one. If the character editor you are using supports the bracket matching function (for example, vi), the most important thing is to have a good style. Why? We say that when you have a large program and want to know where it ends. Move the brackets to the beginning, and press the button editor to find the ending brackets. for example:
If (veryLongCondition & secondVeryLongCondition)
{
...
}
Else if (...)
{
...
}
To move from one block to another, you only need to use the cursor to match your brackets. no matching brackets are needed.