 |
|
 |
Control flow - Labels | A Wisdom Archive on Control flow - Labels |  | Control flow - Labels A selection of articles related to Control flow - Labels |  |
|
More material related to Control Flow can be found here:
|
|
|  | |
Control flow, Control flow - Anecdotal evidence, Control flow - Arithmetic IF, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Collection-controlled loops, Control flow - Condition-controlled loops, Control flow - Conditions in PL/I, Control flow - Control structures in practice, Control flow - Count-controlled loops, Control flow - Early exit from loops, Control flow - Exceptions in C++ and derived languages, Control flow - General iteration, Control flow - Goto, Control flow - Infinite loops, Control flow - Labels, Control flow - Loop with test in the middle, Control flow - Loops, Control flow - Minimal structured control flow, Control flow - Multiple early exit/exit from nested loops, Control flow - Primitives, Control flow - Proposed control structures, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Subroutines, Goto, Subroutine, Main loop, Recursion, Spaghetti code, Structured programming, Functional programming
|  | |
|
ARTICLES RELATED TO Control flow - Labels |  |  |  | Control flow - Labels: Encyclopedia II - Control flow - Primitives
Control flow - Labels.
In a few programming languages (e.g. Fortran, BASIC), a label is just a whole number which appears at the beginning of a statement, e.g.
1234 X = 3
In many programming languages, a label is an identifier, which is attached to a statement by using a colon (:), e.g.
Success:print("target has been found")
Historical note: Algol 60 allowed both whole numbers and identifiers as labels (both attached by colons to statements), but few if any implementations allowed whole numbers.
See also: Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Primitives |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Proposed control structuresIn a spoof Datamation article (December 1973), R. Lawrence Clark suggested that the GOTO statement could be replaced by the COMEFROM statement, and provides some entertaining examples. This was actually implemented in the INTERCAL programming language, a language designed to make programs as obscure as possible.
In his 1974 article "Structured Programming with go to Statements", Donald Knuth identified two situations which were not covered by the control structures listed above, and gave examples of control structures which could handle these situations. Despite their utility, these constructions have not ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Proposed control structures |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Anecdotal evidenceThe following statistics apply to a 6000-line compiler written in a private language containing the above constructions.
There are 10 condition-controlled loops, of which 6 have the test at the top, 1 has the test at the bottom, and 3 have the test in the middle.
There are 18 exitwhen statements, 5 with 2 events, 11 with 3 events, and 2 with 4 events. When these were first used in the compiler, replacing various flags and tests, the number of source lines increased by 0.1%, the size of the object code decreased by 3%, an ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Anecdotal evidence |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Structured non-local control flowMany programming languages, particularly those which favor more dynamic styles of programming, offer constructs for non-local control flow. These cause the flow of execution to jump out of a given context and resume at some predeclared point. Exceptions, conditions, and continuations are three common sorts of non-local control constructs.
Control flow - Conditions in PL/I.
PL/1 has some 22 standard conditions (e.g. ZERODIVIDE SUBSCRIPTRANGE ENDFILE) which can be RAISEd and which ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Structured non-local control flow |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Choice
if thing1 > 10:
print'A'
if thing1 > 200:
print 'B'
Control flow - Choice based on specific constant values.
These are usually known as case or switch statements. The effect is to compare a given value with specified constants and take action according to the first constant to match. If the constants form a compact range then this can be implemented very efficiently as if it were a choice based on whole numbers. Th ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Choice |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Minimal structured control flowIn May 1966, Böhm and Jacopini published an article in Communications of the ACM which showed that any program with gotos could be transformed into a goto-free form involving only choice (IF THEN ELSE) and loops (WHILE condition DO xxx), possibly with duplicated code and/or the addition of Boolean variables (true/false flags). Later authors have shown that choice can be replaced by loops (and yet more Boolean variables).
The fact that such minimalism is possible does not necessarily mean that it is desirable; after all, comput ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Minimal structured control flow |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - Control structures in practiceMost programming languages with control structures have an initial keyword which indicates the type of control structure involved (Smalltalk is an exception). Languages then divide as to whether or not control structures have a final keyword.
No final keyword: Algol 60, C, C++, Java, Pascal, PL/1. Such languages need some way of grouping statements together:
Algol 60 and Pascal : begin ... end.
C, C++ and Java: curly brackets { ... }.
PL/1: DO ... EN ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Control structures in practice |
|  |
|
 |  |  | Control flow - Labels: Encyclopedia II - Control flow - LoopsA loop is a sequence of statements which is specified once but which may be carried out several times in succession. The code "inside" the loop (the body of the loop, shown below as xxx) is obeyed a specified number of times, or once for each of a collection of items, or until some condition is met.
In some languages, such as Scheme, loops are often expressed using tail recursion rather than explicit looping constructs.
Control ...
See also:Control flow, Control flow - Primitives, Control flow - Labels, Control flow - Goto, Control flow - Subroutines, Control flow - Minimal structured control flow, Control flow - Control structures in practice, Control flow - Choice, Control flow - Choice based on specific constant values, Control flow - Choice based on whole numbers 1..N, Control flow - Arithmetic IF, Control flow - Loops, Control flow - Count-controlled loops, Control flow - Condition-controlled loops, Control flow - Collection-controlled loops, Control flow - General iteration, Control flow - Infinite loops, Control flow - Early exit from loops, Control flow - Self-modifying code, Control flow - Structured non-local control flow, Control flow - Conditions in PL/I, Control flow - Exceptions in C++ and derived languages, Control flow - Proposed control structures, Control flow - Loop with test in the middle, Control flow - Multiple early exit/exit from nested loops, Control flow - Anecdotal evidence Read more here: » Control flow: Encyclopedia II - Control flow - Loops |
|  |
|
 | |
|
|
More material related to Control Flow can be found here:
|
|
|
 | |