For Gauche 0.9.5

Next: , Previous: , Up: Library modules - R7RS integration   [Contents][Index]

10.3 R7RS library form

R7RS libraries are defined by define-library form.

In R7RS view, define-library form itself does not belong to a Scheme code—it exists outside of the Scheme world. It defines the boundary of R7RS Scheme; inside define-library there is R7RS world, but outside, it’s not a business of R7RS. For example, you can’t generate define-library by a macro, within R7RS specification.

In Gauche, we implement R7RS world inside Gauche world; define-library itself is interpreted in the Gauche world. In fact, define-library is a Gauche macro. However, if you’re writing portable R7RS code, you should forget how define-library is implemented, and do not put anything outside of define-library form.

Macro: define-library library-name library-decl …

[R7RS] Defines a library library-name, which is a list of symbols or base-10 integer:

<library-name> : (<identifier-or-base-10-integer>
                  <identifier-or-base-10-integer> ...)

Library declarations library-decl can be export declarations, import declarations, begin-list of Scheme code, include forms, or cond-expand forms.

<library-decl> : (export <export-spec> …)
               | <import declaration>
               | (begin <command-or-definition> …)
               | (include <string> <string2> …)
               | (include-ci <string> <string2> …)
               | (include-library-declarations 
                        <string> <string2> …)
               | (cond-expand <cond-expand-clause>
                              <cond-expand-clause2> …)
               | (cond-expand <cond-expand-clause>
                              <cond-expand-clause2> …
                              (else <library-decl> …))

The export declaration is the same Gauche’s export form; see Using modules.

The import declaration is R7RS’s import form, described in Three forms of import.

The include and include-ci declarations are the same as Gauche’s; see Inclusions. Note that Gauche allows any code to be included—the content of the named file is simply wrapped with begin and substituted with these forms—but in R7RS definition, what you include must contain only Scheme code (not one of the library declarations or define-library form).

The include-library-declarations declaration works like include, but the content of the read file is interpreted as library declarations instead of Scheme code.

The cond-expand declaration is also the same as Gauche’s; see Feature conditional. When used directly below define-library, it must expands to one of the library declarations.

Next: , Previous: , Up: Library modules - R7RS integration   [Contents][Index]