indent style

<programming>

Rules for formatting code to make it easier to visually match up the beginning and end of a block of statements, particularly one controlled by a control statement such as "if", "else", "for", "while", "do". This becomes important with large, nested blocks of code.

Indent styles vary in the placement of "" and "" with respect to the statement(s) they enclose and the controlling statement.

The normal style is "Allman style", named after Eric Allman, a Berkeley hacker who wrote many BSD utilities in it. It is sometimes called "BSD style". It resembles normal indent style in Pascal and ALGOL. Basic indent per level is eight or four spaces. This is the only indent style to clearly associate the controlling statement and the beginning and the end of the block by aligning them vertically, which probably explains its widespread adoption.

 if (cond)
 {
 <body>
 }

Other styles such as K&R style, Whitesmiths style and GNU style are either obsolete or should be avoided because they make it harder (much harder in some cases) to match braces with each other and with the control statement that controls them.

Many related languages such as Perl offer the same choices while others, following B, eschew braces and rely entirely on relative indentation to express block structure. In Python, braces can be used to override indentation.

[Jargon File]

Last updated: 2014-09-24

Nearby terms:

indentationindent styleIndependent Computing Architecture

Try this search on Wikipedia, Wiktionary, Google, OneLook.



Loading