Indent style
In computer programming, an indent style is a convention governing the indentation of blocks of code to convey the program's structure. This article largely addresses the C programming language and its descendants, but can be (and frequently is) applied to most other programming languages (especially those in the curly bracket family). Indent style is just one aspect of programming style.
BSD/Allman style
The BSD/Allman style is relatively common. It puts the brace associated with a control statement on the next line, indented to the same level as the control statement. Statements within the braces are indented to the next level.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
while(x == y)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
something();
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
somethingelse();
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
}
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
finalthing();
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
Proponents of this style believe that the indented code is clearly set apart from the containing statement by lines that are almost completely whitespace; the braces line up with the statement they conceptually belong to; and the ending brace lines up with the beginning brace.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
One disadvantage of this style is that each of the enclosing braces occupies an entire line without adding any visible instructions. This once was a very important consideration when programs were usually edited on terminals that displayed only 24 lines, but is less significant now.
~ ~ ~ ~ ~ ~ ~ ~ ~ ~
~ Table of Content ~
| ► | Introduction |
| ► | K&R style |
| ► | BSD/Allman style |
| ► | Whitesmiths style |
| ► | GNU style |
| ► | Pico style |
| ► | See also |
~ What's Hot ~
~ Community ~
| ► | History Forum Come and discuss about History, Civilizations, Historical Events and Figures |
| ► | History Web-Ring A community of sites, blogs and forums dedicated to History. Do not hesitate to submit your site. |
and are licensed under the GNU Free Documentation License.
Lexicon - Privacy Policy - Spiritus-Temporis.com ©2005.