A library is
module declaration for use by multiple
programs. MzScheme provides a mechanism for grouping libraries into
collections that can be easily distributed and easily added
to a local MzScheme installation. A collection is normally installed
into a directory named collects that is in the same directory
as the MzScheme executable.54 Each installed
collection is represented as a subdirectory within the
Client programs incorporate a library by using a module path of the
(lib library-file-path collection ···). For
example, the following module uses the match.ss library module
from the default mzlib collection, the getinfo.ss
library module from the setup collection, and the
cards.ss library module from the games collection's
mzscheme(require (lib "match.ss") (lib "getinfo.ss" "setup") (lib "cards.ss" "games" "cards")) ....)
(lib library-file-path collection ···)
accesses the module in the file
library-file-path in the
collection named by the first
collection, where both
collection are literal strings that
will be used as elements in a path. If additional
strings are provided, they are used to form a path into a
subcollection. If the
collection arguments are omitted, the
library is accessed in the mzlib collection.
The info.ss library in a collection is special by convention. This library is used to provide information about the collection to mzc (the MzScheme compiler) or MrEd. For more information see PLT mzc: MzScheme Compiler Manual and PLT MrEd: Graphical Toolbox Manual.
There is usually one standard collects directory, but MzScheme
supports any number of directories containing collections. The search
path for collections is determined by the
current-library-collection-paths parameter (see
section 188.8.131.52). The list of paths in
is searched from first to
last to locate a collection. To find a sub-collection, the enclosing
collection is first found; if the sub-collection is not present in
the found enclosing collection, then the search continues by looking
for another instance of the enclosing collection, and so on. In other
words, the directory tree for each element in the search path is
spliced together with the directory trees of other path
elements. (The ``splicing'' of tress applies only to directories; a
file within a collection is found only within the first instance of
The value of the
is initialized by the stand-alone version of MzScheme to the result
produces a list of paths as follows:
The path produced by
(is the first element of the default collection path list, unless the value of the
If the executable embeds a list of search paths, they are included (in order) after the first element in the default collection path list. Embedded relative paths are included only when the corresponding directory exists relative to the executable.
If the directory specified by
(is absolute, or if it is relative (to the executable) and it exists, then it is added to the end of the default collection path list.
If the PLTCOLLECTS environment variable is defined, it is combined with the default list using
path-list-string->path-list(see section 11.3.2). If it is not defined, the default collection path list (as constructed by the first three bullets above) is used directly.
The path produced by
normally embedded in an executable; in stand-alone MzScheme (or MrEd), it can be
overridden via a --collects or -X command-line flag.
MzScheme is distributed with a standard collection of utility libraries with MzLib as the representative library. The name of this collection is mzlib, so the libraries are distributed in a mzlib subdirectory of the collects library collection directory. MzLib is described in PLT MzLib: Libraries Manual.