Group: repetitive control

topics > computer science > programming > Group: program control

foreach and for all statements
for loop
generalized repetition
multiple for loop
quantified repetition
simple loop
termination of control unit


Repetition along with sequence and selection are the fundamental control structures. Repetition statements have an initialization section, iterated variables, and a termination condition. Pratt argues that loop control should identify its function, e.g., search or sequence generation, separately from the statements controlled. Jackson selects one form of repetition, a simple loop or for-all, to simplify program structure.

Repetition can sometimes be replaced by recursion or simplified with a sentinel. For instance tail-recursion is equivalent to a simple loop. (cbb 5/80)

Subtopic: social machine up

Quote: a social machine occurs when people perform repeatable actions with repeatable results that can fail to meet standards [»holtAW_1997]

Subtopic: loop variables up

Quote: the loop control computation should be clearly identified [»pratT3_1978]
Quote: specify loops with initialization, incrementation, termination tests, and alternative paths [»pratT3_1978, OK]
Quote: repetitive control requires some way to record state; uses a invocation parameter that acts as a named constant [»redeDH7_1979]
Quote: del control primitive for APL; e.g., x.del.1000 repeats x 1000 times [»vanbFH12_2001]

Subtopic: historical examples up

Quote: Babbage developed 'backing' to reexecute a set of cards any number of times [»menaLF10_1842, OK]
Quote: a Jaquard-loom with backing could weave symmetric and regular patterns with fewer cards
Quote: subroutines for the assembly of repetitive programs; like structured programming, but seldom used [»wilkMV_1951]

Subtopic: foreach loops up

Quote: in a 1975 study, most loops generated or scanned a list, vector, or string [»pratT3_1978]

Subtopic: while vs. repeat up

Quote: repeat..until is harder to use correctly since first iteration does not test the conditional; loop body has two distinct contexts [»jackMA_1975]
Quote: in paper solutions with looping constructs, 75% had only a terminating condition [»paneJF2_2001]
Quote: in paper solutions, 85% treated progress as all or nothing instead of counting [»paneJF2_2001]

Subtopic: testing and annotating loops up

Quote: loops are the most error-prone structure; test 0, 1, 2, average, max-1, max, and max+1 iterations [»yamaT11_1998]
Quote: in block schematic diagrams, annotate test arrows with the tested item or loop count

Subtopic: initialization of loops up

Quote: added 'init' predicate for guards; true only during the first execution of a loop [»parnDL8_1983]

Subtopic: continue/break control up

Quote: C's continue statement initiates the next iteration of the immediately enclosing loop [»ritcDM7_1978c]
Quote: C's break statement terminates the immediately enclosing while, for, do, or switch [»ritcDM7_1978c]

Subtopic: loop exit up

Quote: loop exits can allow specialized terminations indicated by a label [»bochGV7_1973, OK]

Subtopic: loop termination with tagged values up

Quote: reduce the number of orders by using tags instead of counting; e.g., use -1 to end a sequence of positive numbers [»wilkMV_1951]

Subtopic: avoid loops up

Quote: all loops should have a fixed upper bound
Quote: the relational model does not need iterative or recursive loops to extract information; few bugs and higher productivity [»coddEF_1990]
QuoteRef: hamiM3_1976 ;;14 loops not allowed in HOS specification. Instead uses recursion with all variables unique and protected
Quote: Hehner's 'if' statement is more robust than Dijkstra's 'do' because it fails if no guard is true, e.g., an unexpected state [»redeDH7_1979]
Quote: can implement Dijkstra's 'do' statement via recursive calls of Hehner's 'if' statement
Quote: in paper solutions, sets or subsets used for 95% of statements on multiple objects; 5% loops or iteration [»paneJF2_2001]
Quote: prefer set and subset expressions over iterative operations; avoids loop counters, terminating flags, and current object

Group: repetitive control up

Topic: foreach and for all statements (16 items)
Topic: for loop (18 items)
Topic: iterator (13 items)
Topic: generalized repetition (16 items)
Topic: multiple for loop (2 items)
Topic: quantified repetition (11 items)
Topic: simple loop
(15 items)

Related Topics up

Topic: recursion (16 items)
Topic: termination of control unit
(22 items)

Updated barberCB 12/04
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.