Previous section To contents Next section

8.2 Where do modules come from?

Modules are not loaded until you use them, which saves memory unless you use all the modules. However, if you want to write your own modules it is important to know how modules are located and loaded.

When you use Stdio Pike will look for that module:

  1. In imported directories.
  2. In directories added with add_module_path()
  3. In directories specified with -M on the command line.
  4. In directories in the environment variable PIKE_MODULE_PATH
  5. In the directory with builtin modules, usually /usr/local/lib/pike/modules/
For each of these directories, Pike will do the following:
  1. If there is a file called Stdio.pmod.pike, Pike will load this Pike program, clone it and use that as a module.
  2. If there is a file called Stdio.pmod.so, Pike will load this with load_module(), clone it and use that as a module.
  3. If there is a directory called Stdio.pmod, Pike will create a module containing all the modules in that directory as identifiers. If there is a module called module in that directory, all identifiers from that module will overload any modules actually present in the directory.
As you can see, quite a lot of work goes into finding the modules, this makes it possible to choose the most convenient way to build your own Pike modules.

Previous section To contents Next section