User guide
2.3. COMMANDS 25
2.3.6 Flow of Co ntrol
The following commands affect the flow of control.
RESULTIS E
RETURN
ENDCASE
LOOP
BREAK
GOTO E
FINISH
RESULTIS causes evaluation of t he sm al le st textually enclosing VALOF expres-
sion to return with t he va lue of E.
RETURN causes evaluat io n of the current routine to terminate.
LOOP causes a jump to the point just after the end of the body of the s m al l-
est textually enclosing repetitive command (see Sec ti o n 2.3.4). For a REPEAT
command, this will cause t h e body to be executed again. For a FOR com-
mand, it causes a jump to where the control variable is incremented, an d for
the REPEATWHILE and REPEATUNTIL commands, it causes a jump to the place
where the controlling expression is re-evaluated.
BREAK causes a jump to the point just after the smallest enclosing repetitive
command (see Section 2.3.4).
ENDCASE causes execution of the command s i n the smallest enclosing SWITCHON
command to complete.
The GOTO command jumps to the com m a n d whose label is the value of E. S ee
Section 2.4.1 for details on how labels are declared. The destination of a GOTO
must be within the currently executing function or routine.
FINISH only remain s in BCPL for historical reasons. It is eq u i valent to the
call stop(0, 0) which causes the current program to stop execution. See the
description of stop(code, res) page 61.
2.3.7 Compound Commands
It is often useful to be able to execute commands in a sequence, and this can be
done by writing the commands one after ano t h er , separated by sem ico l on s and
enclosed in section brackets. The syntax is as foll ows:
{ C
1
;...; C
m
}
where C
1
to C
m
are commands. It i s permissible to have no commands in a
command sequen ce, thus {} is allowed and performs no commands.
Any semicolon occurring at the end of a line may be omi t t ed . For this rule
to work, infixed exp r ess io n operators may ne ver start a line (see Section 2.2.9).