Gauche:ModuleSystem

Gauche has a first class module (namespace), and requre/provide-based library management mechanism. Both are extension of the mechanisms of STk. On top of them there's a convenience macro (use) that is similar to Perl's use or Python's import.

Namespaces

A module can be created declaratively (define-module), or procedurally (make-module?). A module is basically just a global symbol table. It also keeps the visibility control information.

Global bindings can be made visible from other modules by export and export-all syntax. The user of the module can import such bindings by import syntax. Advanced features such as renaming import or selective import are not supported (yet).

Besides using other modules by import, a module can inherit other modules, to extend the original modules (extend?). A module can inherit from multiple modules, exactly like Gauche's class can inherit from multiple classes.

Libraries

A basic require/provide mechanism is used to manage loading library files. It is orthogonal to module systems.

Use form

A special form use just combines require and import for convenience.

  (use srfi-1)   ;; loads library "srfi-1" and imports module srfi-1