while

while p do x -- repeatedly evaluates x as long as the value of p remains true.

This construction is more powerful than might appear at first glance, even though there is no explicit construction in the language that allows one to break out of a loop, because p may be a conjunction of several compound statements. For example, the expression

          while (a(); not b()) and (c(); not d()) do e()
might be used to replace C code that looks like this:
          while (TRUE) { a(); if (b()) break; c(); if (d()) break; e(); }

Go to main index.

Go to concepts index.