Library form

Syntax library name export-clause import-clause body

Declare a library named name.

name uniquely identifies a library and is globally visible in the import clauses of all other libraries. It must have the following form:

(_identifier1 identifier2_ ... _version_)

where version is empty or has the following form: (_sub-version_ ...)An export-clause names a set of imported and locally defined bindings to be exported. It must have following form:

(export _export-spec_ ...)

export-spec must have one of the following forms:

In an export-spec, an identifier names a single binding defined within or imported into the library, where the external name for the export is the same as the name of the binding within the library. A rename spec exports the binding named by identifier1 in each (_identifier1 identifier2_) pairing, using identifier2 as the external name.

import-clause specifies a set of bindings to be imported into the library. It must have the following form:

(import _import-spec_ ...)

Each import-spec specifies a set of bindings to be imported into the library. An import-spec must be one of the following:

An import-level is one of the following:

where level represents an exact integer object.

Note: The levels will be ignored on Sagittarius. The macro expansion phase will be automatically resolved. For portable code, it is better to specify the proper level.

An import-set names a set of bindings from another library and possibly specifies local names for the imported bindings. It must be one of the following:

A reference identifies a library by its name and optionally by its version. It must have one of the following forms:

Note: Sagittarius ignores version.

A reference whose first identifier is for, library, only, except, prefix or rename is permitted only within a library import-set. The import-set(library _reference_) is otherwise equivalent to reference.

By default, all of an imported library's exported bindings are made visible within an importing library using the names given to the bindings by the imported library. The precise set of bindings to be imported and the names of those bindings can be adjusted with the only, except, prefix and rename forms described below.

Note: Sagittarius does not check importing or exporting non-existing or duplicated bindings. So the following code is actually valid.

(library (foo)
  (export bar)
  (import (rename (rnrs) (define def) (not-exist define) (define def)))
 (def bar)
)