repeat is a reserved word in the programming language Lua.

In the BNF syntax of Lua, it appears as a terminal atom in one substitution rule:
statrepeat block until exp1
"stat" appears as a nonterminal atom in one substitution rule:
chunk → {stat [';']}

repeat is one of the three control structures of Lua (the other two being while and if). The condition expression (also called the guard) of a control structure may return any value. All values different from nil are considered true; only nil is considered false.

The body of the loop (block) is executed. From there, the behaviour of the repeat structure is identical to that of the while structure. The condition expression is evaluated, and every time it passes (evaluates to true) the body is executed and the condition expression is evaluated again. Once it fails (evaluates to false), the loop is over.

The flow of control of a repeat loop can be broken by the break statement, as with the while loop. If, in executing the block, Lua runs into a break statement, the rest of the body is skipped, the condition expression is not evaluated, and the program resumes immediately after the end of the control structure. Of course, a break only exits from one loop - a in a loop which is itself nested within a loop, will only exit from the innermost loop. while and for also count as loops, so for example a break in a while in a repeat will break out of the while loop only.

Quite often, a programmer may wish to break out of a loop which is not the innermost loop. Some programming languages provide a feature for naming a loop (or even just a section of code), and add the ability to associate a name with a break - so, in the previous example, if the outer loop was named 'RepeatLoop', then a break RepeatLoop will break out of both loops.

repeat can be implemented in terms of while, as follows:
until exp1
FirstIteration = true
while (exp1 or FirstIteration)
  FirstIteration = false
or, even more simply,
while exp1
while can be expressed in terms of repeat, too, but that requires an extra control structure (an if). Thus, while is considered to be more fundamental a structure than repeat.

The superloop of a program sometimes looks like:
until (true)
The program usually exits by use of the break statement, or through some operating system-provided means, usually an exception (e.g. in BASIC programs, the Escape key used to always exit the program - it was impossible, within early BASICs, to trap the Escape key), or by means of an instruction like exit (which is like a named break, where the name is associated with the entire program rather than any particular part of it).

Re*peat" (-p?t"), v. t. [imp. & p. p. Repeated; p. pr. & vb. n. Repeating.] [F. r'ep'eter, L. repetere; pref. re- re- + petere to fall upon, attack. See Petition.]


To go over again; to attempt, do, make, or utter again; to iterate; to recite; as, to repeat an effort, an order, or a poem.

"I will repeat our former communication."

Robynson (More's Utopia).

Not well conceived of God; who, though his power Creation could repeat, yet would be loth Us to abolish. Milton.


To make trial of again; to undergo or encounter again.



3. ScotsLaw

To repay or refund (an excess received).

To repeat one's self, to do or say what one has already done or said. -- To repeat signals, to make the same signals again; specifically, to communicate, by repeating them, the signals shown at headquarters.

Syn. -- To reiterate; iterate; renew; recite; relate; rehearse; recapitulate. See Reiterate.


© Webster 1913.

Re*peat" (r?-p?t"), n.


The act of repeating; repetition.


That which is repeated; as, the repeat of a pattern; that is, the repetition of the engraved figure on a roller by which an impression is produced (as in calico printing, etc.).

3. Mus.

A mark, or series of dots, placed before and after, or often only at the end of, a passage to be repeated in performance.


© Webster 1913.

Log in or register to write something here or to contact authors.