Next: 1.9 Error handling Up: 1.8 Code organization Previous: 1.8.1 Procedures Contents Index

## 1.8.2 Modules

Onyx provides the infrastructure for loadable modules, which can be implemented in Onyx and/or dynamically loaded machine code (shared libraries). See the require and mrequire documentation for details on how to load modules.

When writing a module that is meant as a library of additional functionality, some choices have to be made about how to organize the module. Some of the obvious choices for how to organize the loaded definitions are:

- Insert definitions into globaldict.
- Create a new dictionary full of definitions, and insert the dictionary into globaldict as, say, foodict.
- Create a new dictionary full of definitions, and put the dictionary on dstack somewhere, such as directly above or below systemdict. Note that this can be done by the application manually, so simply creating the dictionary and letting the application insert it where it pleases could be a better choice.
- Insert definitions into systemdict (questionable practice).

Depending on the nature of the module, any of the above solutions may be the right choice. There are tradeoffs between convenience and cleanliness that should be carefully weighed.

Next: 1.9 Error handling Up: 1.8 Code organization Previous: 1.8.1 Procedures Contents Index