Block (programming): Difference between revisions

Content deleted Content added
Reverted to revision 956131001 by DannyS712 bot (talk): WP:DISRUPTIVE (TW)
No edit summary
Tags: Visual edit Mobile edit Mobile web edit
Line 3:
 
{{Programming paradigms}}
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 those having the same name used elsewhere. In a block-structured programming language, the objects named in outer blocks are visible inside inner blocks, unless they are [[Name masking|masked]] by an object declared with the same name.
 
==History==
Ideas of block structure were developed in the 1950s during the development of the first [[autocode]]soyone alone, and were formalized in the [[Algol 58]] and [[Algol 60]] reports. Algol 58 introduced the notion of the "compound statement", which was related solely to [[control flow]].<ref name="algol58_report">{{cite journal
|last1= Perlis |first1 = A. J. |authorlink1=Alan Perlis
|last2= Samelson |first2= K.