Block (programming)

blockblocksblock structuredcode blockcode blocksBlock structureblock structuresblocks of statementsALGOL-like lexical scoping mechanismsblock of code
In computer programming, a block or code block is a lexical structure of source code which is grouped together.wikipedia
78 Related Articles

Structured programming

structuredProgram structurestructured program
Blocks are fundamental to structured programming, where control structures are formed from blocks.
Structured programming is a programming paradigm aimed at improving the clarity, quality, and development time of a computer program by making extensive use of the structured control flow constructs of selection (if/then/else) and repetition (while and for), block structures, and subroutines.

ALGOL 60

ALGOLALGOL 60 programming languageAlgol 60 Report
Ideas of block structure were developed in the 1950s during the development of the first autocodes, and were formalized in the Algol 58 and Algol 60 reports.
It followed on from ALGOL 58 which had introduced code blocks and the and pairs for delimiting them.

Statement (computer science)

statementstatementscompound statement
Blocks consist of one or more declarations and statements.

ALGOL 58

International Algebraic Language1958 Preliminary ReportALGOL
Ideas of block structure were developed in the 1950s during the development of the first autocodes, and were formalized in the Algol 58 and Algol 60 reports.
ALGOL 58 introduced the fundamental notion of the compound statement, but it was restricted to control flow only, and it was not tied to identifier scope in the way that Algol 60's blocks were.

Control flow

looploopscontrol structure
Blocks are fundamental to structured programming, where control structures are formed from blocks.
A set of statements is in turn generally structured as a block, which in addition to grouping, also defines a lexical scope.

Scope (computer science)

scopelexical scopeLexical
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.
A scope is a part of a program that is or can be the scope for a set of bindings—a precise definition is tricky, but in casual use and in practice largely corresponds to a block, a function, or a file, depending on language and type of entity.

ALGOL

ALGOL 60ALGOL programming languageALGOrithmic Language
ALGOL introduced code blocks and the ... pairs for delimiting them.

C (programming language)

CC programming languageC language
C program source text is free-format, using the semicolon as a statement terminator and curly braces for grouping blocks of statements.

Off-side rule

indentationsignificant whitespaceline-oriented design
A computer programming language is said to adhere to the off-side rule if blocks in that language are expressed by their indentation.

Python (programming language)

PythonPython programming languagePython 2
Python uses whitespace indentation, rather than curly brackets or keywords, to delimit blocks.

Scheme (programming language)

SchemeScheme programming languageR6RS
In the above Scheme fragment, empno is used to identify both the manager and his or her underlings each by their respective ssn, but because the underling ssn is declared within an inner block it does not interact with the variable of the same name that contains the manager's ssn.
He suggested that ALGOL-like lexical scoping mechanisms would help to realize their initial goal of implementing Hewitt's Actor model in Lisp.

Pascal (programming language)

PascalPascal programming languageISO 7185
Use of blocks in the above fragment of Pascal clarifies the programmer's intent, and enables combining the resulting blocks into a nested hierarchy of conditional statements.
Pascal programs start with the program keyword with a list of external file descriptors as parameters (not required in Turbo Pascal etc.); then follows the main block bracketed by the begin and end keywords.

Computer programming

programmingcodingprogrammable
In computer programming, a block or code block is a lexical structure of source code which is grouped together.

Source code

codesourcesource file
In computer programming, a block or code block is a lexical structure of source code which is grouped together.

Declaration (computer programming)

declarationdeclarationsdeclared
Blocks consist of one or more declarations and statements.

Name resolution (programming languages)

name resolutionname maskingdynamic-named
In a block-structured programming language, the objects named in outer blocks are visible inside inner blocks, unless they are masked by an object declared with the same name.

Autocode

Glennie AutocodeMark 1 Autocode
Ideas of block structure were developed in the 1950s during the development of the first autocodes, and were formalized in the Algol 58 and Algol 60 reports.

Guarded Command Language

guarded commandsGuarded CommandGuarded commands, nondeterminacy and formal derivation of programs

Nested function

nestednested subroutinesLocal function
Some languages which support blocks with declarations do not fully support all declarations; for instance many C-derived languages do not permit a function definition within a block (nested functions).