Repeat Statements
Bananattack edited this page May 8, 2011
·
8 revisions
The Language Reference - Repeat Statements
Repeat statements provide a convenient way to generate to write loops that execute once, and then repeat as long their condition is still false. They have the form repeat ...statements until condition
, where statements consist of the code to execute one or more times as long as the condition is false, and condition is a condition argument, similar to one that could be passed to [[goto ... when |Branches]]
.
x: get #30
repeat
x: dec
until zero
// This code is equivalent to the above, except that the labels are completely private in the former.
x: get #30
begin
def loop:
begin
x: dec
end
goto loop when not zero
end
If you wish to repeat a loop unconditionally, you can use the form repeat ...statements end
, where statements are the code to repeat unconditionally. You can still break out of the loop by other means, such as a goto statement.
repeat
call player.move
end
// Equivalent to the above, but with private label, except that the labels are completely private in the former.
begin
def loop:
begin
call player.move
end
goto loop
end