4.4. Lexical Scoping

The system maintains a stack of objects called input frames to track input sources. Input can be stacked using the "@include_file()" command, which is equivalent to a subroutine call. The stack is popped when the included file is exhausted.

The commands "@begin()" and "@end()" can also be used to push and pop the input stack, this is equivalent to a nested block.

User defined symbols are lexically scoped. The system currently maintains a dictionary of user symbols with each stack frame: all assignments enter the symbol into the dictionary of the top of stack frame.

When the stack is pushed, the new top of stack dictionary is initialised by a copy of the old top of stack dictionary. User symbols are searched for first in the top of stack user dictionary, and then in the global interscript namespace.

As well as supporting scoped symbols, the parser is scoped. That is, changes to lexicology or processing mode made by modifying the parser tables are lost when the frame is dropped. This ensures that, for example, a change to the warning character in an included file does not affect the interpretation of the including file.