User guide
30 CHAPTER 2. THE BCPL LANGUAGE
(@x)!1, (@x)!2,. . . where x is t he first argument. This feature is useful in the
definition of functions, such as writef, having a variable number of arguments.
The scope of the formal par a m et er s is the body of the function or routine.
Function and routine calls are cheap in both space and execution time, with
a typical space overhead of t hree words of stack per call plus one word for each
formal parameter. In the Cintcode implementation, the execution overhe ad is
typically just one Cintcode instruction for the call and one for the return.
There are two important restriction s concerning functions and routines. One
is tha t a GOTO command cannot make a jump to a label not declared within the
current function or routine, although such non local jumps can be made using
level and longjump, described on pa ge 54. The other is that dynamic free
variables are not permitted.
2.4.9 Dynamic Free Variables
Free variabl es of a funct i on or routine are those that are used but not declared in
the function or routine, and they are restricted to be either manifest constants,
static variabl es, global variables, functions, routines or labels. This implies that
they are not permitted t o be dynamic variables (ie local variab les of anot h er
function or routine). There are several reasons for this restriction, including the
ability to r ep r ese nt a function or routine by a single BCPL word, the ability to
provide a safe separate compilation with th e related ability to assig n functions
and routines to variables. It also allows call s to be efficient. Programmers used
to languages such as Algol or Pascal will find that they need to change their
programming style somewhat; however, most experienced BCPL users agree that
the restriction is well worthwhile. Note that C adopted the same restriction,
although in that language it is imposed by the simple expedient of insisting
that all function are declared at the outermost level, thus making dyna m ic free
variables syntacticall y impossible.
A style of programming that is often be used to avoid the dynamic free vari ab l e