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:
_identifier_
(rename (_identifier1 identifier2_) ...)
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:
import-set
(for _import-set_ _import-level_ ...)
An import-level is one of the following:
run
expand
(meta _level_)
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:
reference
(library _reference_)
(only _import-set_ _identifier_ ...)
(except _import-set_ _identifier_ ...)
(prefix _import-set_ _identifier_)
(rename _import-set_ (_identifier1 identifier2_) ...)
A reference identifies a library by its name and optionally by its version. It must have one of the following forms:
(_identifier1 identifier2_ ...)
(_identifier1 identifier2_ ... _version_)
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.
An only
form produces a subset of the bindings from another
import-set, including only the listed _identifier_s. The included
_identifier_s should be in the original import-set.
An except
form produces a subset of the bindings from another
import-set, including all but the listed _identifier_s. All of the
excluded _identifier_s should be in the original import-set.
A prefix
form adds the identifier prefix to each name from
another import-set.
A rename
form (rename _identifier1 identifier2_ ...)
,
removes the bindings for identifier1 ... to form an intermediate
import-set, then adds the bindings back for the corresponding
identifier2 ... to form the final import-set. Each
identifier1 should be the original import-set, each
identifier2 should not be int the intermediate import-set, and
the identifier2's must be distinct.
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)
)