Next: , Previous: , Up: The Poke Language   [Contents][Index]

18.19 Modules

It is common for pickles to depend on stuff defined in other pickles. In such cases, the load language construction can be used to load pickles from your Poke program. The syntax is:

load module;

where module is the name of the pickle to load.

For example, your Poke program may want to access some ELF data structures. In that case, we can just do:

/* Pickle to poke the contents of some ELF section.  */

load elf;

/* … code  … */

When asked to open a module, poke assumes it is implemented in a file named In the example above, it will try to load

The pickles are searched first in the current working directory. If not found, then prefix/share/poke/ is tried next.

If the environment variable POKEDATADIR is defined, it replaces prefix/share/poke. This is mainly intended to test a poke program before it gets installed in its final location.

Nothing prevents you to load the same pickle twice. This will work if the pickle doesn’t include definitions, but just executes statements. Otherwise, you will likely get an error due to trying to define stuff twice.

There is an alternate syntax of the load construction that is useful when the module is implemented in a file whose name doesn’t conform to a Poke identifier. This happens, for example, when the file name contains hyphens. Example:

load "";

Note that if you use this variant of load, you must specify the full file name, including whatever extension it uses (usually .pk).

Next: , Previous: , Up: The Poke Language   [Contents][Index]