Next: , Previous: , Up: Scheme reference   [Contents][Index]


6.16 Modules

The (hoot modules) module provides a way to reflect and interact with Hoot’s runtime module system. The runtime module system is typically reserved for development builds only, as its main use case is for interactive development and their presence significantly increases binary size. To use the runtime module system, ensure that programs are compiled with -gruntime-modules.

Parameter: the-root-module

Parameter containing the current root of the runtime module graph.

Procedure: module? obj

Return #t if obj is a module.

Procedure: make-empty-module [#:name '()] [#:root #f]

Return a fresh, empty module named name whose root module is root.

Procedure: module-name module

Return the name of module.

Procedure: module-root module

Return the root module for module.

Procedure: module-export! module name [src-name] [#:replace? #f]

Export src-name (name by default) as name in module. If replace? is #t then an existing export may be overwritten. Otherwise, an exception is raised in the event that the export already exists.

Procedure: module-import! dst src name [src-name]

Import the exported symbol name from module src into module dst as src-name (name by default).

Procedure: module-exported-names module

Return a list of names exported from module.

Procedure: module-imported-modules module

Return a list of modules imported by module.

Procedure: module-bound? module name [#:private? #f]

Return #t if name is bound in module. By default, name is looked up in the module’s public namespace. To perform lookup in the private namespace instead, set private? to #t.

Procedure: module-ref module name [#:private? #f]

Return the top-level variable associated with name in module. By default, name is looked up in the module’s public namespace. To perform lookup in the private namespace instead, set private? to #t.

Procedure: module-set! module name value [#:mutable-imports? #f] [#:private? #f]

Set the top-level variable associated with name in module to value. If mutable-imports? is #t then imported variables are allowed to be modified, otherwise an exception is raised. By default, name is looked up in the module’s public namespace. To perform lookup in the private namespace instead, set private? to #t.

Procedure: module-define! module name value [#:allow-redefinition? #f] [#:mutable? #t]

Define a top-level variable in module named name set to value. If mutable? is #t (the default) then the variable will be mutable. If allow-redefinition? is #t then any previous definition of name will be clobbered. By default, redefinition is not allowed and an exception will be raised.

Procedure: resolve-module module name [#:load? #f] [#:define? #f]

Return the module named name in module’s module graph. If no such module exists then one of a few things may happen. If load? is #t then try to load the module from source using current-module-loader. If define? is #t then ensure that an empty module is created and return that. If all of the previous resolution strategies fail or are disabled then return #f.

Syntax: current-module

Return a runtime module for the module in which this form is expanded.

Parameter: current-module-loader

Parameter containing the current procedure used for loading modules from source code.


Next: REPL, Previous: Finalization, Up: Scheme reference   [Contents][Index]