Next: , Previous: , Up: Modules   [Contents][Index]

6.19.4 Modules and the File System

Typical programs only use a small subset of modules installed on a Guile system. In order to keep startup time down, Guile only loads modules when a program uses them, on demand.

When a program evaluates (use-modules (ice-9 popen)), and the module is not loaded, Guile searches for a conventionally-named file from in the load path.

In this case, loading (ice-9 popen) will eventually cause Guile to run (primitive-load-path "ice-9/popen"). primitive-load-path will search for a file ice-9/popen in the %load-path (see Load Paths). For each directory in %load-path, Guile will try to find the file name, concatenated with the extensions from %load-extensions. By default, this will cause Guile to stat ice-9/popen.scm, and then ice-9/popen. See Load Paths, for more on primitive-load-path.

If a corresponding compiled .go file is found in the %load-compiled-path or in the fallback path, and is as fresh as the source file, it will be loaded instead of the source file. If no compiled file is found, Guile may try to compile the source file and cache away the resulting .go file. See Compilation, for more on compilation.

Once Guile finds a suitable source or compiled file is found, the file will be loaded. If, after loading the file, the module under consideration is still not defined, Guile will signal an error.

For more information on where and how to install Scheme modules, See Installing Site Packages.