Statements
Every statement is an expression, optionally followed by a modifier, and terminated with a semicolon. The semicolon may be omitted if the statement is the final one in a block.
Execution of expressions can depend on other expressions using one of the modifiers if
, unless
, while
, or until
, for example:
expr1if
expr2 ; expr1until
expr2 ;
The logical operators | |, & &, or ? : also allow conditional execution:
expr1 | | expr2 ; expr1 ? expr2 : expr3 ;
Statements can be combined to form a block when enclosed in { }. block s may be used to control flow:
if
(expr) block [ [elsif
(expr) block...]else
block ]unless (
expr) block [else
block ][ label: ]
while
(expr) block [continue
block ][ label: ]
until
(expr) block [continue
block ][ label: ]
for
( [ expr ] ; [ expr ] ; [ expr ] ) block[ label: ]
foreach
var(dagger) (list ) block[ label: ] block [
continue
block ]
Program flow can be controlled with:
goto
label- Continue execution at the specified label.
last
[ label ]- Immediately exits the loop in question. Skips continue block.
next
[ label ]- Starts the next iteration of the loop.
redo
[ label ]- Restarts the loop block without evaluating the conditional again.
Special forms are:
do
blockwhile
expr ;do
blockuntil
expr ;
which are guaranteed to perform block once before testing expr, and
do
block
which effectively turns block into an expression.