28
while ( true )
{
    // what is each time through this loop called?
}

4 Answers4

226

I would call it an iteration. I don't know if everyone would.

psr
  • 12,866
  • 5
  • 39
  • 67
  • 141
    Everyone would. – Scott C Wilson Jul 26 '11 at 00:13
  • 10
    The definition of "iteration" in the PC-based dictionary I use (WordWeb Pro) is: "a single execution of a set of instructions that are to be repeated", which fits perfectly with "once through this a loop". So I agree. – tcrosley Jul 26 '11 at 00:15
  • @psr What would it be called to do a single iteration? –  Jul 26 '11 at 00:46
  • I don't have a nice short way to say that using some form of "iterate". So even though I would usually prefer that over "loop" or "pass" because of all the patterns and interfaces with some version of "iterate" in the name that make it a more specific technical term, I might just call it a pass, depending on the context. So maybe librik deserves a little more upvote love. – psr Jul 26 '11 at 01:06
  • There's another answer here: "Pass". Either can be used. These days, iteration seems to be more common. – quickly_now Jul 26 '11 at 02:01
  • iteration baby. – surfasb Jul 26 '11 at 02:29
  • Yar... iteration... and the i that is often used in for loops is called the iterator... and a sweep over all objects in an array is called a traversal. – Michael Jul 26 '11 at 03:00
  • 4
    @quickly_now : "Pass" is commonly used when the code executed differs in each pass. For instance, a two-pass compiler typically has a 'parse' and 'link' pass. – MSalters Jul 26 '11 at 08:35
  • @MSalters: Yes, I know. I also started programming back in the 1980's, and back then "pass" seemed to be a more common term. These days, its fallen out of favour, and "iteration" seems to be more prevalent. – quickly_now Jul 26 '11 at 08:49
  • @quickly_now: I disagree, I haven't had your experience with the word pass as a synonym for iteration. – Vinko Vrsalovic Jul 26 '11 at 10:00
  • 1
    @jay I would say what you said, a single iteration. That makes it clear it was part of a loop that ended early. – jhocking Jul 26 '11 at 12:56
  • So if I were to tell a loop to do an iteration, would it make sense to tell it to "iterate"? The problem is that "iterate" sounds like looping indefinitely, not just once. If this makes any sense. –  Jul 26 '11 at 17:09
  • @Jay: Just tell it to "iterate once". Or something like that. – JAB Jul 26 '11 at 18:44
45

The code inside: body

An execution of the body: iteration

whatsisname
  • 27,703
18

The usual term is a "pass". For example: "This code makes ten passes through the loop. On each pass it computes a local maximum. The best result so far was found during the previous pass and it will be improved this pass."

librik
  • 345
  • 1
  • 6
5

These days, "iteration" has become the most common general usage. While "pass" has indeed been used, and is still occasionally seen, it is generally semantically bound more to the transfer of values and references as arguments to method parameters.

John Tobler
  • 436
  • 3
  • 7