2.4.1. Name Space

[<<<] [>>>]

The scriba syntax analyzer implements a simple name space handling. A variable, label or function name always belongs to a name space. The default name space is main. When the syntax analyzer processes a non-absolute symbol it converts the name to contain the name space. A variable named var in the name space main has the name main::var. The syntax analyzer automatically converts the name to contain the name space, therefore main::var and var are equivalent when used in the name space main.

When a variable contains double colon it is treated as an absolute name, and no name space is prepended to it. If you are in the name space module and use the variable name main::var it will NOT be converted to module::main::var. The reason is that it already contains the characters :: and therefore scriba assumes that it already contains the name space.

If you are in the name space module and want to refer to the variable module::main::var you can use the names module::main::var or ::main::var. The first format contains all nested name spaces to the variable. The second version tells the syntax analyzer that the variable is relative, altough it contains double colon. This is because it starts with double colons.

If you are in name space module::submodul and want to refer to the variable module::var you can either write module::var or _::var. The first format contains all nested name spaces to the variable. The second version tells the syntax analyzer that the variable is relative and the base module is the embedding module of the current one.

If you are familiar with the UNIX or DOS/Windows directory notation you can find similarities of file names and name space in scriba. In file names double dot means the parent directory. In scriba underscore character means the parent name space. You can use the _ character not only in front of a name, but also within :: characters. For example

Main::module::var
Main::module::submodule::_::var
Main::_::Main::module::var

are equivalent.

Name spaces help to separate variables and to develop scripts cooperatively, but does not prohibit one name space to access variables or symbols of other name spaces.


[<<<] [>>>]