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:
- In imported directories.
- In directories added with add_module_path()
- In directories specified with -M on the command line.
- In directories in the environment variable PIKE_MODULE_PATH
- In the directory with builtin modules, usually /usr/local/lib/pike/modules/
For each of these directories, Pike will do the following:
- If there is a file called Stdio.pmod.pike, Pike will load this
Pike program, clone it and use that as a module.
- If there is a file called Stdio.pmod.so, Pike will load this
with load_module(), clone it and use that as a module.
- 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.