You are looking at historical revision 28116 of this page. It may differ significantly from its current revision.
This extension extends the module form to allow to associate type-specifications with module exports, for example:
(use typed-modules) (module stack ((make-stack : (-> (struct stack))) (push : ((struct stack) * -> void)) (pop : ((struct stack) -> *)) (empty? : ((struct stack) -> boolean))) (import scheme) ;; definitions of "make-stack", "push", "pop" and "emtpy?" follow ... )
The expanded module will contain type-declarations for all exports for which types have been given. Normal export-lists without types are still supported, as are all other variants of the module form.
More specifically, the syntax of module has been extended to allow the following:[syntax] (module NAME (EXPORT-SPEC1 ...) BODY ...)
[syntax] (module NAME SIGNATURENAME BODY ...)
EXPORT-SPEC may be one of
|(IDENTIFIER : syntax [IDENTIFIER1 ...])||syntax export with optional indirect exports|
|(IDENTIFIER : TYPE)||value export with type|
|((IDENTIFIER1 ...) : TYPE)||the same as (IDENTIFIER1 : TYPE) ...|
Additionally, the default meaning of export lists is still supported:
|IDENTIFIER||a value or syntax export|
|(syntax: IDENTIFIER1 ...)||syntax epxort, optionally with indirect exports|
|(interface: INTERFACENAME)||exports from given interface|
|(IDENTIFIER1 ...)||a syntax export with indirect exports|
The module defined implicitly imports : (the type declaration form).
SIGNATURENAME should be the name of a signature, which is a compile-time construct that names a set of (optionally typed) exports:[syntax] (signature SIGNATURENAME (EXPORT-SPEC1 ...))
Defines a signature with the given name and export-specifiers and implicitly defines an interface (as with define-interface) for the exported identifiers.
Signatures can not be exported and are only valid in the compilation unit in which they are defined. If you want to share a signature over several files, it is recommended to use an include file.
This extension has no runtime code, it is sufficient to use import instead of use.
Copyright (c) 2013, 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.
- initial version