modules

A simple module system for use with the low-level (define-macro) macro system. Import and export of macros is not allowed.

In combination with the -emit-exports compiler option, this module system provides some minimal interoperability with the (much more powerful) module system provided by the syntax-case extension.

module

[syntax] (module [NAME] (EXPORT ...) BODY ...)

Defines a named or anonymous module. The EXPORTs should be identifiers and name bindings exported by this module. The bindings must be defined (using define) in BODY, either at it's toplevel or nested in begin forms. If an exported binding is not defined, an error will be signalled. All other toplevel bindings defined in BODY will be hidden and not be accessible from outside of this module.

import

[syntax] (import NAME)

Imports exported bindings from the module with the name NAME. If a module with the required name was previously defined, then all the following expressions may access the imported bindings. If no module is known under this name, then an installed extension will be searched that exports identifiers that are qualified with NAME. If no such extension can be found, then a file named NAME.exports will be searched in the current include-path and qualified identifiers from it will be extracted. If neither an installed extension nor an .exports file lists any qualified export, then an error will be signalled.

If used inside a module form, then the imported bindings will only be accessible inside the lexical scope of the module. If used outside of a module form, then the values of imported bindings will be assigned to toplevel variables of the same name, overwriting any existing bindings.

import*

[syntax] (import* NAME IMP ...)

Imports selective with optional renaming. Only the identifiers given in IMP ... will be imported from the module NAME, where IMP may be either an identifier or a list of the form (NEW OLD).

export-toplevel

[syntax] (export-toplevel IDENTIFIER ...)

Exports the values given by the (possibly non-exported) module bindings IDENTIFIER ... as toplevel variables of the same name. IDENTIFIER may also be of the form (IDENTIFIER EXPORT), which exports the module binding IDENTIFIER as toplevel variable EXPORT.

Authors

Requirements

License

Copyright (c) 2006-2007, Felix L. Winkelmann
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
Neither the name of the author nor the names of its contributors
may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.