User guide
32 CHAPTER 2. THE BCPL LANGUAGE
When these sections are l oa d ed , global 200 is initialized to the entry point of
function f defined in demolib.b and so is can be call ed from the functi on start
defined in demomain.b.
The header file, libhdr, contains the global decl ar at i ons of all the resident
library functions and routines maki n g all these accessible to any section that
started with: GET "libhdr". The library is described in the next chapter. Global
variable 1 is called start and is, by convention, the first function to be called
when a program is ru n .
Automatic global initialisation also occurs if a label declared by colon (:)
occurs in the scope of a global of the same name.
Although the global vector mechanism has disadvantages, particularly in the
organisation of library packages, there are some compensating benefits arising
from its extreme sim p l i ci ty. One is that the output of the compiler is available
directly for execution without the need for a link editing step. S ect i on s may
also be loaded and unloaded dynamically during the execution of a program
using th e library functions loadseg and unloadseq, and so arbitrary overlaying
schemes can be organised easily. An examp le of where thi s is used is in the
implementation of the Command Language Interpreter described in Chapter 4.
The global vector also allows for a simple but effective interactive debuggin g
system without the need for compiler constructed symbol tables. Again, this was
devised when machines were small, disc space was very limited and modern day
linkage ed i t or s had not been invented; however, some of its advantages are still
relevant today.
2.6 The objline1 Feature
If a file named objline1 is found in the current directory or the other directories
searched by GET directives, its first line is cop i ed as the first line of the compiled
Cintcode module. This will typically put a line such as:
#!/usr/local/bin/cintsys -c
as the first line of the compiled object module. Thi s line is ignored by the CLI
but under Linux it allows Cintcode programs to be called directly from a Linux
shell. If objline1 canno t be found no such li ne is inserted at the start of the
object module.