Previous: Module Monkey, Up: Module System Internals
This section describes how to support usage of fixed global bindings for the module system internals, and how to migrate a site installation away from that. New code should use the module interface to the module system internals (see Module Monkey).
Normally there are three phases to a migration, carried out by the site
administrator, and implemented by creating/modifying the init file in
the site directory: $(GUILE_SITE)/init.scm. This is done by adding to
this file the use-modules form:
(use-modules (ice-9 module-system-compat))
and a properly configured call to the activation proc
activate-global-module-system-bindings!.
For this phase, call the activation proc without any args.
(ice-9 gumm).
For this phase, call the activation proc, passing the explicitly identified
bindings.
(ice-9 gumm); there are no longer
any naked calls to the undocumented module internals.
For this phase, you can comment out the use-modules form and the call
to the activation proc. See below for reasons why not to remove them entirely.
Due to packages outside your control, it may be that you never reach Phase 3 (or even Phase 2). That's ok, too.
Make global bindings for the selected symbols sel, which must be from the following list:
the-root-module the-scm-module module-ref resolve-module current-module eval-in-module module-public-interface set-module-public-interface!Throw error if a specified symbol is not in the list. If sel is null, make bindings for the entire list of symbols. This proc only works on its first call. Subsequent calls do nothing.
Here is an example $(GUILE_SITE)/init.scm file that supports old-style
executable modules, requiring module-ref and resolve-module;
environment capturing code, requiring current-module; and tricky
compiled module code that munges the public interface directly, such as that
used in Guile-PG 0.17 and 0.18.
(use-modules (ice-9 module-system-compat))
(activate-global-module-system-bindings!
'module-ref
'current-module
'set-module-public-interface!
'module-public-interface
'resolve-module)
Note that this example demonstrates Phase 2 usage.
make installTo ensure the least amount of surprise for everyone, the installation process
automatically adds Phase 1 support but only if either the init file does not
exist, or if the string activate-global-module-system-bindings cannot
be found therein.
For this reason, if the site eventually moves to Phase 3, and the forms are no longer necessary, you should at least maintain a small comment in the file, like so:
;; Hey, activate-global-module-system-bindings
;; is no longer necessary -- we are in phase 3!
Doing so prevents future installations from modifying the file.