[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.11.2 Defining and selecting modules

Special Form: define-module name body ...
Name must be a symbol If a module named name does not exist, create one. Then evaluates body sequentially in the module.

Special Form: select-module name
Makes a module named name as the current module. It is an error if no module named name exists.

If select-module is used in the Scheme file, its effect is limited inside the file, i.e. even if you load/require a file that uses select-module internallly, the current module of requirer is not affected.

Special Form: with-module name body ...
Evaluates body sequentially in the module named name. Returns the last result(s). If no moudle named name, an error is signalled.

Special Form: current-module
Evaluates to the current module in the compile context. Note that this is a special form, not a function. Module in Gauche is statically determined at compile time.
 
(define-module foo
  (export get-current-module)
  (define (get-current-module) (module-name (current-module))))

(define-module bar
  (import foo)
  (get-current-module)) => foo ; not bar



This document was generated by Ken Dickey on November, 28 2002 using texi2html