User guide

26 CHAPTER 2. THE BCPL LANGUAGE
In extended BCPL compilerd by xbcpl a more binding version of the sequenc-
ing operator is a allowed. It is the symbol <> and behaves like semicolon but is
more binding than DO, THEN, ELSE, REPEATWHILE, REPEATUNTIL and REPEAT. It
purpose is to reduce the need for section brackets ({ o r }) as in
IF x<y DO t:=x <> x:=y <> y:=t
which is equivalent to:
IF x<y DO { t:=x; x:=y; y:=t }
2.3.8 Blocks
A block is similar to a compound command but may start with some declarations.
The syntax is as follows:
{ D
1
;...; D
n
; C
1
;...; C
m
}
where D
1
to D
n
are delarations and C
1
to C
m
are commands. The declarations
are executed in sequence to initialise any variabl es declared. A name may be used
on the right hand side of its own and succeeding declarations and the commands
(the body) of the blo ck.
2.4 Declarations
Each n a m e used in BCPL progr am must in the scope of its decla r at i on . The
scope of names declared at the outermost level of a program include the right
hand side of its own declaration and all the remaining declarati on s i n t he section.
The scope of nam es declared at the head of a block include the right hand side of
its own declaration, the succeeding declara t io n s and the body of the b l ock. Such
declarations are intro d u ced by the keywords MANIFEST, STATIC, GLOBAL and LET.
A name is also declared when it occurs as the control variable of a for loop. The
scope of such a name is the body of th e for loop.
2.4.1 Labels
The only other way to declare a name is as a label of the form N:. This may
prefix a command or occur just before the closing section bracket of a compound
command or b l ock. The scope of a label is the body of the block or compound
command in which it was declared.