Programming style: Difference between revisions

Content deleted Content added
 
(2 intermediate revisions by 2 users not shown)
Line 19:
 
=== Indentation ===
Indentation style can assist a reader in various wayways including: identifying control flow and blocks of code. In some programming languages, indentation is used to [[off-side rule|delimit blocks of code]] and therefore is not matter of style. In languages that ignore whitespace, indentation can affect readability.
 
For example, formatted in a commonly- used style:
 
<syntaxhighlight lang="c">
Line 74:
 
===== Python =====
{{Further|Python (programming language)}}
'''Python''' relies on the ''[[off-side rule]]'', using indenting to indicate and implement control structure, thus eliminating the need for bracketing (i.e., <code>{</code> and <code>}</code>). However, copying and pasting indented code can cause problems, because the indent level of the pasted code may not be the same as the indent level of the target line. Such reformatting by hand is tedious and error prone, but some [[text editor]]s and [[integrated development environment]]s (IDEs) have features to do it automatically. There are also problems when indented code is rendered unusable when posted on a forum or web page that removes whitespace, though this problem can be avoided where it is possible to enclose code in whitespace-preserving tags such as "&lt;pre&gt; ... &lt;/pre&gt;" (for [[HTML]]), "[code]" ... "[/code]" (for [[bbcode]]), etc.