source: project/wiki/modules @ 7232

Last change on this file since 7232 was 7232, checked in by felix winkelmann, 13 years ago

updated for srfi-89 and minor fixes

File size: 5.0 KB
Line 
1[[tags: egg]]
2[[toc:]]
3
4
5== modules
6
7A simple module system for use with the low-level ({{define-macro}})
8and [[syntactic-closures]] macro systems. Import and export of macros
9is not allowed.
10
11In combination with the {{-emit-exports}} compiler option, this module
12system provides some minimal interoperability with the (much more
13powerful) module system provided by the
14[[http://www.call-with-current-continuation.org/eggs/syntax-case.html|syntax-case]]
15extension.
16
17When used with the
18[[http://www.call-with-current-continuation.org/eggs/syntax-case.html|syntax-case]]
19macro system, this extension does nothing.
20
21Mote that any alternative macro expander ([[syntactic-closures]], for
22example) must be loaded/required prior to using this extension, as it
23must be aware of the expander used.
24
25=== module
26
27 [syntax] (module [NAME] (EXPORT ...) BODY ...)
28
29Defines a named or anonymous module. The {{EXPORT}}s should be identifiers and name bindings exported by this
30module. The bindings must be defined (using {{define}}) in {{BODY}}, either at it's toplevel or nested in
31{{begin}} forms. If an exported binding is not defined, an error will be signalled. All other toplevel bindings
32defined in BODY will be hidden and not be accessible from outside of this module.
33
34Definitions recognized are any of the following:
35
36 (define ID VAL)
37 (define (ID . LLIST) BODY ...)
38 (define* (ID . LLIST) BODY ...)
39 (define (... (ID . LLIST) ...) BODY ...)    ; "curried" define
40 (define* (... (ID . LLIST) ...) BODY ...)    ; "curried" define
41 (define-values (ID ...) VAL)
42 (include FILENAME)                ; recursively expands body
43
44=== import
45
46 [syntax] (import NAME)
47
48Imports exported bindings from the module with the name {{NAME}}. If a module with the required name was
49previously defined, then all the following expressions may access the imported bindings.
50If no module is known under this name, then an installed extension will be searched that exports identifiers
51that are qualified with {{NAME}}. If no such extension can be found, then a file named {{NAME.exports}} will
52be searched in the current include-path and qualified identifiers from it will be extracted.
53If neither an installed extension nor an {{.exports}} file lists any qualified export, then
54an error will be signalled.
55
56If used inside a {{module}} form, then the imported bindings will only be accessible inside the lexical
57scope of the module. If used outside of a {{module}} form, then the values of imported bindings will
58be assigned to toplevel variables of the same name, overwriting any existing bindings.
59
60=== import*
61
62 [syntax] (import* NAME IMP ...)
63
64Imports selective with optional renaming. Only the identifiers given
65in {{IMP ...}} will be imported from the module {{NAME}}, where
66{{IMP}} may be either an identifier or a list of the form {{(NEW OLD)}}.
67
68=== export-toplevel
69
70 [syntax] (export-toplevel IDENTIFIER ...)
71
72Exports the values given by the (possibly non-exported) module bindings {{IDENTIFIER ...}} as toplevel
73variables of the same name. {{IDENTIFIER}} may also be of the form {{(IDENTIFIER EXPORT)}}, which exports
74the module binding {{IDENTIFIER}} as toplevel variable {{EXPORT}}.
75
76
77== Authors
78
79[[felix winkelmann]]
80
81
82== Requirements
83
84[[codewalk]]
85
86[[http://www.call-with-current-continuation.org/eggs/miscmacros.html|miscmacros]]
87
88== License
89
90 Copyright (c) 2006-2007, Felix L. Winkelmann
91 All rights reserved.
92 
93 Redistribution and use in source and binary forms, with or without
94 modification, are permitted provided that the following conditions
95 are met:
96 
97  Redistributions of source code must retain the above copyright
98    notice, this list of conditions and the following disclaimer.
99  Redistributions in binary form must reproduce the above copyright
100    notice, this list of conditions and the following disclaimer in the
101    documentation and/or other materials provided with the distribution.
102  Neither the name of the author nor the names of its contributors
103    may be used to endorse or promote products derived from this
104    software without specific prior written permission.
105 
106 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
107 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
108 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
109 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
110 HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
111 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
112 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
113 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
114 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
115 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
116 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117
118== Version History
119
120; 0.7 : added srfi-89 support
121; 0.6 : supports curried {{define}} syntax
122; 0.5 : added support for [[syntactic-closures]]
123; 0.4 : added {{import*}}
124; 0.3 : added codewalk requirement to meta file
125; 0.2 : {{import}} is now also allowed outside of {{module}} form
126; 0.1 : initial release
Note: See TracBrowser for help on using the repository browser.