Next: Guile API, Previous: Virtual Functions, Up: Guile
[Contents][Index]
The following configuration statement causes loading and
initialization of the guile
module:
load-module mod-name { command "guile init-script=script" " init-fun=function"; }
Upon module initialization stage, the module attempts to load the
file named script. The file is loaded using
primitive-load
call (see Loading in The Guile Reference Manual), i.e. the load paths are not
searched, so script must be an absolute path name. The
init-fun
parameter supplies the name of the initialization
function. This Scheme function constructs virtual
function tables for the module itself and for each database that uses
this module. It must be declared as follows:
(define (function arg) ...)
This function is called several times. First of all, it is called after
the script is loaded. This time it is given #f
as its
argument, and its return value is saved as a global function table.
Then, it is called for each database
statement that has
mod-name (used in load-module
above) in its
handler
keyword, e.g.:
database { name db-name; handler "mod-name …"; }
This time, it is given db-name as its argument and the value it returns is stored as the virtual function table for this particular database.
The following example function returns a complete virtual function table:
(define-public (my-dico-init arg) (list (cons "open" open-module) (cons "close" close-module) (cons "descr" descr) (cons "info" info) (cons "lang" lang) (cons "define" define-word) (cons "match" match-word) (cons "output" output) (cons "result-count" result-count)))