Indentation style

In computer programming, indentation style is a convention, a.k.a. style, governing the indentation of blocks of source code that is intended to result in code that conveys structure.

Indentation involves using the same width of whitespace before each line of a group of code so that they appear to be related. As whitespace consists of both space and tab characters, a programmer can choose which to use often entering them via the keyboard space key or tab key.

Indentation applies to every text-based programming language. This article primarily addresses free-form languages, with special attention to curly-bracket languages (that delimit blocks with curly brackets, a.k.a. curly braces, a.k.a. braces) and in particular C-family languages.

As the name implies, free-form language code need not follow an indentation style. Indentation is a secondary notation that is often intended to lower cognitive load for a programmer to understand the structure of the code. Indentation can clarify the separation between the code executed based on control flow.

Some free-from languages use keywords instead of braces for example BEGIN and END.

Structured languages, such as Python and occam, use indentation to determine the structure instead of using braces or keywords; this is termed the off-side rule. In such languages, indentation is meaningful to the language processor (such as compiler or interpreter); not just the programmer.

A convention used for one language can be adapted for another language.

This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.