User guide
12 CHAPTER 2. THE BCPL LANGUAGE
variant of GPM, called BGPM, is included in the standard BCPL distribution.
BCPL was initially similar to this subset of CPL used in the encoding of
the CPL com p i l er . An outline of BCPL’s main fea t u r es first appeared in my
PhD thesis [4] in 1966 but it was not fully designed and implemented until early
the following year when I was working at Project MAC of the M assa chussetts
Institute of Technology. Its first implementation was written in Ross’s Algol
Extended for Design (AED-0)[1] which was the only language then available on
CTSS, the time sharing system at Project MAC, other than LISP that allowed
recursion.
2.1 Language Overv i ew
A BCPL program is made up of separately compiled sections, each consisting of a
list of declarations that define the constants, static data and fun ct i on s belonging
to the section. With in functions it is possible to declare dynamic var i ables and
vectors that exist only as long as they are required. The language is designed so
that these dynam i c quantities can be al located space on a runtime stack. The
addressing of these quantities is relative to the base of the stack frame belonging
to the current function activation. For this to be efficient, dynamic vectors have
sizes that are known at compile time. Functions may be called recursively and
their arguments are called by value. The effect of call by reference can be achieved
by passing pointers. Input and output and other system operations are provided
by means of library functions.
The main syntactic components of BCPL are: expressions, commands, and
declarations. These are described in the next few sections. In general, the pur-
pose of an expression is to compute a value, while the purpose of a command is
normally to change the value of one or more vari ables or to perform input/output .
2.1.1 Comments
There are two form of comments. O ne starts with the symbol // and extends
up to but not including the end-of-line character, and the other starts with t h e
symbol /* an d ends at a matching occurrence of */. Comment brackets (/*
and */ may be nested, and within such a comments the lexical an al yse r is only
looking for /* and */ and so care is needed wh en commenting out fragments of
program containing string constants. Comments are equivalent to white space
and so may not occur in the middle of multi - character symbols such as id entifiers
or constants.