Control Flow Flashcards
Basic Paradigms for Control Flow
(T/F)
Details in syntax and semantics do not differ between languages.
False
Seven Categories for Control Flow
- Sequencing
- Selection
- Iteration
- Procedural Abstraction
- Recursion
- Non-Determinacy
- Concurrency
Describe Sequencing.
Statements are to be executed in a particular order, usually in the order appearing in the program text.
Define Selection.
- A choice is made between two or more alternatives (statements or expressions) depending on a condition determined at runtime.
- If, case (switch) statements.
Describe Iteration.
- A given code fragment is executed repeatedly, either a given number of times or until a runtime condition is satisfied.
- While, do, repeat loops.
Describe Procedural Abstraction.
A potentially complex collection of control constructs is encapsulated so that it can be treated as a single unit, often subject to parameterization.
Describe Recursion.
- An expression is defined in terms of simpler versions of itself.
- The computational model requires a stack on which to save information about partially evaluated instances of the expression.
- Usually defined using self-referential subroutines.
Describe Non-Determinacy.
- The ordering or choice among statements or expressions is deliberately left unspecified.
- Any alternative should lead to a correct result.
- Sometimes “fairness” is required.
Define Concurrency.
- Two or more program fragments are to be executed “at the same time”, either in parallel on separate processors or interleaved in a single processor.
Sequencing
Imperative VS Functional Languages
- Central to imperative languages.
- Minor importance in functional languages, which emphasize expression evaluation.
Recursion
Imperative VS Functional Languages
- Crucial in functional languages
- Available in imperative languages
Iteration
Imperative VS Functional Languages
- Emphasized in imperative languages.
Precedence Associativity
Assignments
Construct Side Effects