WHILE statement

Language reference ›› Statements ››
Parent Previous Next

while-statement = WHILE boolean-expression DO block .

The WHILE statement is optimized for boolean use, but in non-strict mode PMP also accepts a non-boolean expression: any value that is not zero is evaluated as TRUE (1).


Optimizations:


If <boolean-expression> evaluates to a constant value equal to 0 (FALSE), no code is generated for the <boolean-expression> evaluation and for the <block>.

If <boolean-expression> evaluates to a constant value not equal to 0 (TRUE), no code is generated for the <boolean-expression> evaluation, the <block> is generated and loops forever.


The loop flow may also be controlled via BREAK and CONTINUE statements.


See also: BREAK, CONTINUE.