(index ("module" 0) ("module" 0) ("module" 0) ("module" 0) ("module" 0) ("export" 3170) ("import" 3526) ("import-for-syntax" 4492) ("reexport" 4946) ("define-interface" 5412) ("module-environment" 5886) ("functor" 6651))
(def (sig (syntax "(module NAME (EXPORT ...) BODY ...)" (id module)) (syntax "(module NAME (EXPORT ...) FILENAME)" (id module)) (syntax "(module NAME * BODY ...)" (id module)) (syntax "(module NAME1 = NAME2 [BODY ...])" (id module)) (syntax "(module NAME = (FUNCTORNAME MODULENAME1 ...))" (id module))) (p "Defines a module with the name " (tt "NAME") ", a set of exported bindings and a contained sequence of toplevel expressions that are evaluated in an empty syntactical environment.") (p (tt "(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. " (tt "EXPORT") " may have any of the following forms:") (p (tt "IDENTIFIER") " names a value- or syntax binding to be exported.") (p (tt "(IDENTIFIER1 ...)") " or " (tt "(syntax: IDENTIFIER1 ...)") " exports " (tt "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).") (p (tt "(interface: INTERFACENAME)") " adds all exports defined for the given interface to be added to the list of exported identifiers of this module.") (p "As a special case, specifying " (tt "*") " instead of an export-list will export all definitions. As another special case, the export-list may be a symbol naming an interface.") (p "When the " (tt "BODY") " consists of a single string, it is treated like " (tt "(include FILENAME)") ".") (p (tt "(module NAME = (FUNCTORNAME MODULENAME1 ...))") " instantiates a " (i "functor") " (see below for information about functors).") (p "The syntax " (tt "(module NAME1 = NAME2)") " defines an alias " (tt "NAME1") " for the module " (tt "NAME2") ", so " (tt "NAME1") " can be used in place of " (tt "NAME2") " in all forms that accept module names. Module aliases defined inside a module are local to that module. If followed by a module body, then this is a special form of " (i "functor instantiation") ".") (p "Nested modules, modules not at toplevel (i.e. local modules) or mutually recursive modules are not supported. As an exception module alias definitions are allowed inside a module definition.") (p "When compiled, the module information, including exported macros is stored in the generated binary and available when loading 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.") (p "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 do many other module systems. Redefinition or assignment of value or syntax bindings will modify the original, imported definition.") (p "Syntax expansions may result in module-definitions, but must be at toplevel."))
(def (sig (syntax "(export EXPORT ...)" (id export))) (p "Allows augmenting module-exports from inside the module-body. " (tt "EXPORT") " is if the same form as an export-specifier in a " (tt "module") " export list. An export must precede its first occurrence (either use or definition).") (p "If used outside of a module, then this form does nothing."))
(def (sig (syntax "(import IMPORT ...)" (id import))) (p "Imports module bindings into the current syntactical environment. The visibility of any imported bindings is limited to the current module, if used inside a module-definition, or to the current compilation unit, if compiled and used outside of a module.") (p "Importing a module does not load or link it - this is a separate operation from importing its bindings.") (p (tt "IMPORT") " may be a module name or an " (i "import specifier") ", where a module name is either a symbol or a list of the form " (tt "(srfi N)") ". An " (tt "IMPORT") " defines a set of bindings that are to be made visible in the current scope.") (p "Note that the imported bindings are only visible in the next toplevel expression (regardless of whether the import appears inside or outside a module):") (pre " (begin\n   (import m1)\n   ...)              ; imports not visible here\n \n ...                ; imports visible here"))
(def (sig (syntax "(import-for-syntax IMPORT ...)" (id import-for-syntax))) (p "Similar to " (tt "import") ", but imports exported bindings of a module into the environment in which macro transformers are evaluated.") (p "Note: currently this isn't fully correct - value bindings are still imported into the normal environment because a separate import environment for syntax has not been implemented (syntactic bindings are kept separate correctly)."))
(def (sig (syntax "(reexport IMPORT ...)" (id reexport))) (p "Imports " (tt "IMPORT ...") " and automatically exports all imported identifiers. This can be used to build " (i "compound modules") ": modules that just extend other modules:") (highlight scheme "(module r4rs ()\n  (import scheme chicken)\n  (reexport \n    (except scheme \n      dynamic-wind values call-with-values eval scheme-report-environment\n      null-environment interaction-environment)))"))
(def (sig (syntax "(define-interface INTERFACENAME (EXPORT ...))" (id define-interface))) (p "Defines an " (i "interface") ", a group of exports that can be used in module-definitions using the " (tt "(interface: INTERFACE)") " syntax. See the definition of " (tt "module") " above for an explanation of " (tt "EXPORT") " specifications.") (p "Interface names use a distinct global namespace. Interfaces defined inside modules are not visible outside of the module body."))
(def (sig (procedure "(module-environment MODULENAME)" (id module-environment))) (p "Locates the module with the name " (tt "MODULENAME") " and returns an environment that can be passed as the second argument to " (tt "eval") ". The evaluated expressions have only access to the bindings that are visible inside the module. Note that the environment is not mutable.") (p "If the module is not registered in the current process, " (tt "module-environment") " will try to locate meta-information about the module by loading any existing import library with the name " (tt "MODULENAME.import.[scm|so]") ", if possible.") (p "In compiled modules, only exported bindings will be visible to interactively entered code. In interpreted modules all bindings are visible."))
(def (sig (syntax "(functor (FUNCTORNAME (ARGUMENTMODULE1 EXPORTS1) ...) FUNCTOREXPORTS BODY)" (id functor))) (p "Defines a \"functor\", a parameterized module.") (p "This functor definition does not generate any code. This is done by " (i "instantiating") " the functor for specific input modules:") (highlight scheme "(module MODULENAME = (FUNCTORNAME MODULENAME1 ...))") (p "Inside " (tt "BODY") ", references to " (tt "ARGUMENTMODULE") " will be replaced by the corresponding " (tt "MODULENAME") " argument. The instantiation expands into the complete functor-code " (tt "BODY") " and as such can be considered a particular sort of macro-expansion. Note that there is no requirement that a specific export of an argument-module must be syntax or non-syntax - it can be syntax in one instantiation and a procedure definition in another.") (p (tt "ARGUMENTMODULE") " may also be a list of the form " (tt "(ALIAS DEFAULT)") " to allow specifying a default- or optional functor argument in case the instanation doesn't provide one. Optional functor arguments may only be followed by non-optional functor arguments.") (p "The common case of using a functor with a single argument module that is not used elsewhere can be expressed in the following way:") (highlight scheme "(module NAME = FUNCTORNAME BODY ...)") (p "which is the same as") (highlight scheme "(begin\n  (module _NAME * BODY ...)\n  (module NAME = (FUNCTORNAME _NAME)))") (p "Since functors exist at compile time, they can be stored in import-libraries via " (tt "-emit-import-library FUNCTORNAME") " or " (tt "-emit-all-import-libraries") " (see " (int-link "Using the compiler") " for more information about this). That allows you to import functors for later instantiation. Internally, a functor-definition also defines a module with the same name, but importing this module has no effect. It also has no runtime code, so it is sufficient to merely " (tt "import") " it (as opposed to using " (tt "require-extension") " or one of its variants, which also loads the run-time part of a module).") (p "Note that functor-instantiation creates a complete copy of the functor body."))
