*** Welcome to piglix ***

Indent style


In computer programming, an indent style is a convention governing the indenting of blocks of code to convey program structure. This article largely addresses the free-form languages, such as C and its descendants, but can be (and often is) applied to most other programming languages (especially those in the curly bracket family), where whitespace is otherwise insignificant. Indent style is only one aspect of programming style.

Indenting is not a requirement of most programming languages, where it is used as secondary notation. Rather, indenting helps better convey the structure of a program to human readers. Especially, it is used to clarify the link between control flow constructs such as conditions or loops, and code contained within and outside of them. However, some languages (such as Python and occam) use indenting to determine the structure instead of using braces or keywords; this is termed the off-side rule. In such languages, indenting is meaningful to the compiler or interpreter; it is more than only a clarity or style issue.

This article uses "brackets" to refer to what are termed parentheses in American English, and "braces" to refer to what are termed curly brackets in American English.

The main difference between indent styles lies in the placing of the braces of the compound statement ({...}) that often follows a control statement (if, while, for...). The table below shows this placement for all the styles discussed in this article. For consistency, the indent depth has been kept constant at 4 spaces, regardless of the preferred indent depth of each style.


...
Wikipedia

...