~ chicken-core (chicken-5) 0efffa77b0b29d1807552d29fff74d56709356fd
commit 0efffa77b0b29d1807552d29fff74d56709356fd
Author: felix <felix@call-with-current-continuation.org>
AuthorDate: Sun Mar 20 22:38:12 2011 +0100
Commit: felix <felix@call-with-current-continuation.org>
CommitDate: Sun Mar 20 22:38:12 2011 +0100
export validates export list; started functor docs
diff --git a/expand.scm b/expand.scm
index dde1c707..4e45422f 100644
--- a/expand.scm
+++ b/expand.scm
@@ -1360,25 +1360,17 @@
'()
(##sys#er-transformer
(lambda (x r c)
- (let ((exps (cdr x))
+ (let ((exps
+ (##sys#validate-exports
+ (##sys#strip-syntax (cdr x))
+ 'export))
(mod (##sys#current-module)))
(when mod
- (for-each
- (lambda (exp)
- (when (and (not (symbol? exp))
- (let loop ((iexp exp))
- (cond ((null? iexp) #f)
- ((not (pair? iexp)) #t)
- ((not (symbol? (car iexp))) #t)
- (else (loop (cdr iexp))))))
- (##sys#syntax-error-hook 'export "invalid export syntax" exp (module-name mod))))
- exps)
(set-module-export-list!
mod
(let ((xl (module-export-list mod)))
- (if (eq? xl #t)
- #t
- (append xl (map ##sys#strip-syntax exps))))))
+ (or (eq? xl #t) ; ==> #t
+ (append xl exps)))))
'(##core#undefined)))))
diff --git a/manual/Modules b/manual/Modules
index 510e548c..e0b3f0c7 100644
--- a/manual/Modules
+++ b/manual/Modules
@@ -46,19 +46,32 @@ CHICKEN's module system has the following features and shortcomings:
Defines a module with the name {{NAME}}, a set of exported bindings
and a contained sequence of toplevel expressions that are evaluated in
-an empty syntactical environment. {{EXPORT}} may be a symbol or a list
-of the form {{(IDENTIFIER1 IDENTIFIER2 ...)}}. In the former case the
-identifier given is exported from the module and can be imported at
-the toplevel or in other modules. The latter case exports
+an empty syntactical environment.
+
+{{(EXPORT ...)}} should be an export-specification which holds a list
+of identifiers to be exported from the module and which should be
+visible when imported into another module or the toplevel
+environment. {{EXPORT}} may have any of the following forms:
+
+{{IDENTIFIER}} names a value- or syntax binding to be exported.
+
+{{(IDENTIFIER1 ...)}} or {{(syntax: IDENTIFIER1 ...)}} exports
{{IDENTIFIER1}} (which should name a macro) and also arranges for the
remaining identifiers in the list to be visible in the expansion of
the macro (this is a hint to the module expander to export bindings
referenced by syntax-definitions which make use of them, but which
would normally be internal to the module - which gives more
-opportunities for optimization).
+opportunities for optimization).
+
+{{(interface: INTERFACENAME)}} adds all exports defined for the given
+interface to be added to the list of exported identifiers of this
+module.
+
+As a special case, specifying {{*}} instead of an export-list
+will export all definitions.
-When the {{BODY}} consists of a single string, it is handled
-as {{(include FILENAME)}}.
+When the {{BODY}} consists of a single string, it is treated
+like {{(include FILENAME)}}.
Nested modules, modules not at toplevel (i.e. local modules) or
mutually recursive modules are not supported.
@@ -69,9 +82,6 @@ it into interpreted or compiled code. Note that this is different
to normal macros (outside of module declarations), which are normally
not exported from compiled code.
-As a special case, specifying {{*}} instead of an export-list
-will export all definitions.
-
Note that the module system is only a device for controlling the
mapping of identifiers to value or syntax bindings. Modules do not
instantiate separate environments that contain their own bindings, as
@@ -177,6 +187,16 @@ other modules:
</enscript>
+=== define-interface
+
+<macro>(define-interface INTERFACENAME (EXPORT ...))</macro>
+
+Defines an ''interface'', a group of exports that can be used in
+module-definitions using the {{(interface: INTERFACE)}} syntax.
+See the definition of {{module}} above for an explanation of
+{{EXPORT}} specifications.
+
+
=== import libraries
''import libraries'' allow the syntactical (compile-time)
@@ -319,16 +339,17 @@ the binding information and exported syntax of the former
must be available separately.
-=== Caveats
+=== Functors
-The macro- and module system has been implemented relatively
-recently and is likely to contain bugs. Please contact the
-maintainers if you encounter behavior that you think is
-not correct or that triggers an error where there shouldn't
-be one.
+A ''functor'' is a higher-order module that expands can be
+parameterized with other modules. A functor defines the body of a
+module for a set or argument modules and can be instantiated with
+concrete module names specializing the code contained in the
+functor. This is best explained with an example:
-* In evaluated code, loading a file containing module information and importing from a module contained in that file will not work when the loading and import is performed in the same toplevel expression (this does not apply, when import libraries are used)
-* Currently value bindings imported by {{import}} and {{import-for-syntax}} share the same import-environment.
+<enscript highlight=scheme>
+XXX need example here...
+</enscript>
---
diff --git a/modules.scm b/modules.scm
index 09e277c1..2203ab20 100644
--- a/modules.scm
+++ b/modules.scm
@@ -772,4 +772,3 @@
"argument module `" (symbol->string mname) "' does not match required signature "
"in instantiation `" (symbol->string name) "' of functor `"
(symbol->string fname) "'")))))))
-
Trap