Next: 1.8.1 Procedures Up: 1. Onyx Language Tutorial Previous: 1.7.3 Substituting Contents Index

# 1.8 Code organization

As mentioned earlier, Onyx does not have named variables in the same way as most other languages do. However, it does have the dictionary stack (dstack), which is dynamically used for name lookups whenever an executable name is interpreted. This section talks about how to effectively manage the namespace provided by dstack.

When the Onyx interpreter is first initialized, there are four dictionaries on dstack:

- userdict
- globaldict
- systemdict
- threaddict

dstack can be manipulated any way the application sees fit, though it is generally dangerous to remove or significantly modify systemdict or threaddict, since there are definitions in those dictionaries that are critical to the correct functioning of the interpreter.

Each thread has its own userdict, which provides a thread-local namespace. globaldict is shared among all threads, so it provides a global namespace. systemdict contains all of the default global definitions, and threaddict contains the default thread-local definitions.

For some applications, it may be desirable to add definitions to systemdict, but care should be taken not to overwrite existing definitions unless you really know what you are doing. In most cases, using globaldict is a better way to go.

Subsections

- 1.8.1 Procedures
- 1.8.2 Modules

Next: 1.8.1 Procedures Up: 1. Onyx Language Tutorial Previous: 1.7.3 Substituting Contents Index