Content deleted Content added
Remove two instances of "he or she" |
Slight reword so we don't have to say "variables and other objects", just say "objects" |
||
Line 5:
In [[computer programming]], a '''block''' or '''code block''' is a lexical structure of [[source code]] which is grouped together. Blocks consist of one or more [[Declaration (computer programming)|declarations]] and [[Statement (computer science)|statements]]. A programming language that permits the creation of blocks, including blocks nested within other blocks, is called a '''block-structured programming language'''. Blocks are fundamental to [[structured programming]], where [[control structure]]s are formed from blocks.
The function of blocks in programming is to enable groups of statements to be treated as if they were one statement, and to narrow the [[lexical scope]] of objects such as variables, procedures and functions declared in a block so that they do not conflict with
==History==
Line 61:
==Limitations==
Some languages which support blocks with
==Basic semantics==
Line 146:
In a few circumstances, code in a block is evaluated as if the code were actually at the top of the block or outside the block. This is often colloquially known as ''hoisting'', and includes:
* [[Loop-invariant code motion]], a compiler optimization where code in the loop that is invariant is evaluated before the loop;
* [[Variable hoisting]], a scope rule in JavaScript, where variables have function scope, and behave as if they were declared (but not defined) at the top of a function.
==See also==
|