Next: , Previous: Bindings Browsing, Up: Module System Internals


36.3.2 Module Monkey

Whenever there is modularity there is the potential for misunderstanding: Hiding information implies a need to check communication. —Alan Perlis

To access module system reflection procedures, evaluate the form:

     (use-modules (ice-9 gumm))

To avoid horrible confusion (and perpetuate a different horrible confusion), we use the term fob (which stands for "fancy obarray") to describe the data structure that makes up the parts of a user-visible "module".

— Scheme Procedure: fob-info object [aspects...]

Return #f if object is not a fob. Otherwise, return info on the fob depending on aspects. If aspects is not specified, return #t. If aspects is a single keyword, return the information associated with that keyword. Otherwise, return a vector composed of the information associated with each specified keyword in aspects, in order.

Recognized keywords and their associated information:

#:name
The name, a list of symbols, for example (ice-9 q).
#:kind
A symbol, one of: directory, interface, autoload.
#:uses
A possibly-empty list of other fobs that this object uses.
#:obarray
The hash table mapping symbols to variables. The name “obarray” is a historical artifact.
#:eval-closure
The eval-closure procedure.
#:public-interface
Another fob that describes the exported (also called public) bindings available of object, or #f if that does not make sense (for example, in the case where object is already an interface fob).

— Scheme Procedure: current-module

Return the environment that represents the "module in focus". This is suitable for passing to eval-in-module, for example.

— Scheme Procedure: eval-in-module exp module

Evaluate expression exp in the environment module. You can obtain such an environment by evaluating a combination of define-module and current-module forms, for example.

— Scheme Procedure: eval-in-current-module-proc

Capture the environment of the current module.

Return a procedure that takes an expression exp and evaluates it in the captured environment. During evaluation the current module is set to the one corresponding to the captured environment.

NOTE: This procedure is EXPERIMENTAL. It is likely the module system will provide direct support for this functionality via a define-module clause prior to Guile 1.4.2 release.

— Scheme Procedure: disable-module-catalogs!

Turn off module catalogs support for this Guile session. This action is not reversible.

— Scheme Procedure: module-catalog-manager command [args...]

Do command with the module catalog subsystem, one of:

#:name-to-cat-entry name
Return the module catalog entry associated with name, or #f if no such entry can be found. name is a list of symbols, like (ice-9 q).
#:set-catalog-name! filename
Normally, module catalogs are named .module-catalog (note initial period). This command changes it to filename, which should be a filename without any directory component. This command automatically calls #:recheck-catalogs!, immediately below.
#:recheck-catalogs! [dir...]
Update cached catalog info (if any) for each directory dir, or from %load-path if given no arguments. This is useful after changing %load-path or after doing a chdir in the case where %load-path (or dir...) contains a relative directory name.

Any other command is an error.