For Development HEAD DRAFTSearch (procedure/syntax/module):

9.29 gauche.reload - Reloading modules

Module: gauche.reload

In the development cycle, you often have to reload modules frequently. This module supports it.

Note that some part of semantics of the program depends on the order of loading modules, so reloading arbitrary modules may change the program behavior unexpectedly. This module is for developers who knows what they are doing.

Redefinition rules: Reloading a module resets all the binding in the module by default. Sometimes it is not desirable, however. For example, you might want to keep an intermediate results in some variable. You can specify rules for the reloading procedure to determine which binding to keep.

The rule is described in the following syntax.

  <module-rules> : (<module-rule> ...)
  <module-rule>  : (<module-pattern> <rule> ...)
  <module-pattern> : a symbol module name, or a symbol containing glob pattern
  <rule>         : procedure | symbol | regexp
                 | (and <rule> ...)
                 | (or  <rule> ...)
                 | (not <rule>)

<module-rules> is the global rule to determine per-module rules. <module-pattern> is either a symbol module name or a symbol that contains glob pattern (e.g. mylib.*). If <rule> is a procedure, it is used as a predicate and the bindings whose value satisfies the predicate are kept from redefinition. If <rule> is a symbol, the binding of the variable whose name is the symbol is kept. If <rule> is a regexp, the bindings of the variable whose name matches the regexp are kept.

Note that the mechanism to prevent redefinition is kind of ad-hoc hack and semantically unclean. Especially, the right-hand expressions of defines are still evaluated, so any side effects they have will be in effect (e.g. define-class would still redefine a class). It’s just for your convenience. Take a look at the code if you want to know the exact behavior.

Function: reload module-name :optional rule …

{gauche.reload} Reloads the specified module. You can optionally specify redefinition rules by rule …, where each rule is the term <rule> defined above.

Function: reload-modified-modules :optional module-rules

{gauche.reload} Reloads module(s) that have been modified since they are loaded last time. If optional module-rules is given, it is used to determine the redefinition rules for reloaded modules. If module-rules is omitted, the current rules are used. The default of current rules is empty. You can set the current rules by module-reload-rules.

Function: module-reload-rules :optional module-rules

{gauche.reload} This is a parameter (see Parameters) that keeps the default module rules for reload-modified-modules. If called without arguments, returns the current module rules. If called with module-rules, sets the argument to the current module rules.

Function: reload-verbose :optional flag

{gauche.reload} This is a parameter to control verbosity of the reloading procedures. If called without arguments, returns the current verbosity flag. If called with flag, it is set to the current verbosity flag.



For Development HEAD DRAFTSearch (procedure/syntax/module):
DRAFT