yorick banner

Home

Manual

Packages

Global Index

Keywords

Quick Reference

Yorick Language Reference

Loops

Yorick has three types of loops:

while (condition) body_statement
do body_statement  while (condition)
for (
init_expr ; test_expr ; inc_expr) body_statement

The init_expr and inc_expr of a for loop may be comma delimited lists of expressions. They or the test_expr may be omitted. In particular, for (;;) ... means ``do forever''. If there is a test_expr, the body_statement of the for loop will execute until it becomes false (possibly never executing). After each pass, but before the test_expr, the inc_expr executes. A for loop to make N passes through its body_statement might look like this:

for (i=1 ; i<=N ; i++) body_statement

Within a loop body, the following statements are legal:

break exit the current loop now 
continue abort the current pass through the current loop

For more complex flow control, Yorick supports a goto:
goto label go to the statement after label
label: statement mark statement as a goto target