Difference between revisions of "Loop"

From Computer History Wiki
Jump to: navigation, search
(An OK stub)
 
m (avoid redir)
Line 5: Line 5:
 
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.
 
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. [[C (language)|C]] allows arbitrary statements to initialize the loop, and to be peformed on each pass through the loop; the termination test is an arbitrary [[expression]].
+
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]].

Revision as of 15:57, 16 March 2018

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.