Control flow

From Computer History Wiki
Revision as of 03:48, 6 November 2017 by Jnc (talk | contribs) (An OK stub)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Control flow refers to the means for controlling the order in which sections of a program are executed.

The underlying CPU's instruction set has a number of transfer of control primitives: jump/branch, both un-conditional as well as conditional branches; and subroutine calls.

Programming languages often add additional mechanisms, particularly block structures, in which a group of instructions are treated as a unit for various control mechanisms (e.g. loop control, if-then-else constructs, etc).

Blocks are also often used to control the scope over which variables (particularly local variables) are accessible.

Interrupts and exceptions also divert the flow of control in a computer, but at times which are not always predictable.