For Gauche 0.9.5


Next: , Previous: , Up: Library modules - Gauche extensions   [Contents][Index]

9.2 gauche.base - Importing gauche built-ins

Module: gauche.base

This module exports Gauche built-in procedures and syntaxes, so that they can be imported to other modules that don’t inherit gauche module.

All the bindings available in the gauche module are exported, except import, which is renamed to gauche:import to avoid conflict with R7RS import.

The module extends gauche.keyword, so also exports all the keywords—the bindings from gauche.keyword— so that the code imports gauche.base can access to self-bound keywords without inheriting the keyword module.

Typical Gauche code doesn’t need this module, for built-ins are available by default through inheritance. A newly created module inherits the gauche module by default. (See Module inheritance, for the details.)

Sometimes you need a module that doesn’t inherit the gauche module, yet you want to use Gauche built-in features. Particulary, R7RS libraries and programs require any bindings to be explicitly imported, so R7RS’s import and define-library sets up the module not to inherit the gauche module. In R7RS code, you need (import (gauche base)) to use Gauche’s built-in features.

Another use case is to eliminate some built-in bindings, yet keep the rest of bindings accessible, in your module. For example, the following setup creates almost-gauche module that has almost all default bindings except string-scan and string-split:

(define-module almost-gauche
  (use scheme.r5rs)
  (use gauche.base :except (string-scan string-split)
                   :rename ((gauche:import import)))
  (extend)
  )
(select-module almost-gauche)

;; your code here

Note the empty extend; it empties the module’s inheritance. (The :rename option of gauche.base is just to get the original name of import back in almost-gauche module; if you don’t use import directly, you won’t need it.)


Next: , Previous: , Up: Library modules - Gauche extensions   [Contents][Index]