Block (programming): Difference between revisions

Content deleted Content added
No edit summary
Tags: Reverted Mobile edit Mobile web edit
m Reverted good faith edits by 171.231.76.239 (talk): Previous is fine, no need to change (HG) (3.4.10)
Line 4:
{{refimprove|date=May 2010}}
 
In [[computer programming]], a '''block''' or '''code block''' or '''block of code''' is a lexical structure of [[Source Code|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 [[Nesting (computing)|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.
 
Blocks have two functions: to group statements so that they can be treated as one statement, and to define [[scope (computer science)|scopes]] for [[name binding|names]] to distinguish them from 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 (computer science)|object]] declared with the same name.