Next: Scope and extent Up: Procedures Previous: Recursion

Accessing items in C

We now need to look at when we can make use of a particular name. We have already seen that functions and variables can have names. Variables can be defined at the start of any block, functions only at the outer level.

We have imposed no restriction on re-using names in different contexts, So how do we know, at any given point in a program, whether we can make use of an already-defined name; and which of the possibly several items with the same name this refers to?

This is in fact a more general still: sometimes we wish names to be available outside the file in which they are defined (e.g. the names of library procedures, which would be useless if the user could not name them) and sometimes we do not (e.g. local names within the operating system which the user must not be able to see). This is important in C, which supports multi-file compilation to produce a single runnable program.

To resolve this we have to introduce a few new pieces of jargon and associated concepts.




Next: Scope and extent Up: Procedures Previous: Recursion


maspjw@
Tue Sep 27 15:29:34 BST 1994