diff --git a/refdoc/chapters/modules.xml b/refdoc/chapters/modules.xml new file mode 100644 index 0000000000000000000000000000000000000000..319498da6136cd7aa795a7b8bba1ecc8a70acff6 --- /dev/null +++ b/refdoc/chapters/modules.xml @@ -0,0 +1,82 @@ +<chapter title="Writing Pike Modules"> + <p> + This chapter will discuss how to extend Pike by writing + modules. There are two major ways to write modules, either they + can be written in Pike, or they can be written in C. Generally, + modules can be seen as a collection of pike programs and + functions. This is, obviously, handy for grouping related programs + and functions. + </p> + + <p> + A pike module is actually a pike program which is cloned by the + pike compiler during compilation of programs. This means that all + lfuns that can be used in a pike program also can be used in a + module. This is, for instance, useful for overloading the + operators of a module to obtain a certain behaviour. Bear in mind + that variables defined on a module-wide bases are shared among all + clones of programs in the module. + </p> + + <p> + Pike searches for modules in the module path as defined during the + compilation of a pike program. The module-path defaults to contain + the directory where all standard pike modules are installed. This + can be altered using + <ref>/master.CompatResolver()->add_module_path()</ref> in a + program or by letting the environment variable + <b>PIKE_MODULE_PATH</b> contain a colon-separated list of + directories to be searched for modules before looking at the + default location. + </p> + + <section title="Writing Modules in Pike"> + <p> + Writing modules in pike is by far the easiest way to extend + pike. They are also useful for structuring a larger programming + project into different source files. + </p> + + <p> + There are two ways of create a pike module written in + pike. Either create a file named as the module will be called + with the extension <expr>.pmod</expr> and place all program and + function definitions in it. The other way, which usually is more + flexible, is to create a directory named as the module with the + extension <expr>.pmod</expr> and place all program definitions + (<expr>.pike</expr>-files) within this directory. If a file called + <expr>module.pmod</expr> is placed in the directory de function and + program definitions within it will be merged with the programs + found in the directory. This file could, as an example, be used + to specify functions residing in the module, while programs in + the module are placed in <expr>.pike</expr>-files. + </p> + + </section> + + <section title="Writing Modules in C"> + <p> FIXME: to be written.</p> + </section> + + <section title="Special Module Variables and functions"> + There are a few variables and functions that have a special + meaning in a module. + + <subsection title="_module_value"> + <p> + If <expr>_module_value</expr> is non-zero it will be used as + the value of the module. <expr>_module_value</expr> has to be of + a type which is indicable, ie. an object, mapping och + multiset. + </p> + </subsection> + + <subsection title="The indexing operator"> + <p> + If a <ref>lfun::`[]</ref> is defined in a module it will be + called when the module is indexed using the .-operator. + </p> + </subsection> + </section> + +</chapter> \ No newline at end of file diff --git a/refdoc/structure/traditional.xml b/refdoc/structure/traditional.xml index 055b41b476c1ff40243896292173d185c8f22e22..abe5c3494c23023a191d28daae3a528fa69a2c66 100644 --- a/refdoc/structure/traditional.xml +++ b/refdoc/structure/traditional.xml @@ -5,7 +5,7 @@ <!-- The description in this file will compile a reference manual --> <!-- similar to the old "Pike Tutorial". --> -<!-- $Id: traditional.xml,v 1.9 2001/12/20 15:22:29 nilsson Exp $ --> +<!-- $Id: traditional.xml,v 1.10 2002/02/15 00:18:06 mikael%unix.pp.se Exp $ --> <manual> <dir name="traditional_manual"> @@ -93,6 +93,9 @@ <insert-move entity="Gnome"/> </chapter> </file> + <file> + <chapter-ref file="not_extracted/modules.xml"/> + </file> <file> <chapter title="The rest"> <insert-move entity=""/>