Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

indent style

You are here: irt.org | FOLDOC | 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)
 {
	
 }

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]

(2014-09-24)

Nearby terms: Incremental Prototyping Technology for Embedded Realtime Systems « indent « indentation « indent style » Independent Computing Architecture » Independent Logical File » Independent Verification and Validation

FOLDOC, Topics, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z, ?, ALL

©2018 Martin Webb