Name Space

Name spaces are associated with program elements such as modules, functions, procedures and constructs containing iterators. A name space is created whenever one of these program elements is called (or initialized, or activated). The most recently created name space is referred to as the current name space. The current name space is the target of all definitions.

The purpose of a name space is to keep track of what value a name represents and, in the case of a variable name, what type of value it may represent.

When a name is not found in the current name space, the name space associated with the program element which contains the program element which contains the instruction causing the search is searched, and so on. In other words, name spaces are not searched in the order in which they were created (dynamic scoping), but in the order in which their associated program elements are syntactically nested (static scoping).

For example, the following program prints 1 and 3:

  i : Integer := 1
  p

  proc p
    i : Integer := 2
    q

  proc q
    put i
    i : Integer := 3
    put i
Note that a name may be added to the current name space, even after the name has already been found in an enclosing name space. In other words, the introduction of a name into the current name space hides the name in enclosing name spaces only from the point of definition up to the end of the associated program element.
Herman Venter

This is Slim documentation as snarfed on 27 May 1999 by dB.