Keywords: onyx

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 as Onyx code and/or dynamically loaded machine code (shared libraries). At the lowest level, modload can be used to load a shared object. At a higher level, mrequire can be used to find a shared object in one of the directories specified by the module path, then modload it. At the highest level, the mclass and module classes provide methods for loading, introspecting, and unloading modules. The lower level APIs are typically only utilized when writing modules, and the highest level APIs are utilized when using 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.
- 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