From Computer History Wiki
Jump to: navigation, search

A loop is a construct in a program where a section of the program is executed over and over again; usually there is some test which causes the loop to terminate at some point.

The first programming language to have loops was FORTRAN, which allowed an index variable to start at one constant value, and be incremented (or decremented) by another constant until the value had reached a third constant, at which point the loop terminated. While the loop was active, a block of statements was executed in every pass through the loop.

In assembly language, the same concept applies, except that the loop is constructed manually, using a conditional branch instruction to decide whether or not to terminate the loop, or go around again.

Modern programming languages offer more flexible looping constucts; e.g. the C programming language allows arbitrary statements to initialize the loop, and to be peformed on each pass through the loop; the termination test is an arbitrary expression.