(sph module)

guile module system and rnrs library related procedures

part of sph-lib

library description

# syntax

module-compose :: dest source ...

  define a new module dest with all exported bindings of the specified sources.

  example: (module-compose (my-module) (rnrs base) (rnrs sorting))

import-unexported :: unquoted-module-name unquoted-binding-name

  imports and defines the binding locally at place

module name

(sph module)

exported bindings

procedure: environment* name ... ->
(symbol ...) ... -> environment/module
similar to \"environment\" from (rnrs eval).
this can be used to load modules that use syntax to create their module definition.
the modules contents are first evaluated in the top-level environment - before the environment object is created.
the syntax used for creating the module definition must be available in the current top-level environment.
only the \".scm\" filename-extension is supported when resolving file paths from module names for loading
syntax: import-unexported module-name binding-name
procedure: load-with-environment path env ->
string module ->
load filename and evaluate its contents with the given eval environment which may be a module, a r6rs library or a environment
syntax: module-compose dest-name r6rs-import-spec ...
syntax: module-current-bindings
return a guile-hashtable of all bindings in the current module
procedure: module-dependencies module ->
module -> (module ...)
procedure: module-exports module ->
module -> (symbol ...)
list of exported binding names
procedure: module-file->name a ->
string -> (symbol ...)/false
read file at the given path and, check the first expression for an r6rs or r7rs library definition
and extract the module name
procedure: module-file? path ->
string -> boolean
true if file contains as the first expression an r6rs or r7rs library definition
procedure: module-find path #:max-depth #:load-path #:guile-modules #:ignore-content #:file-content-match #:ignore-load-path #:enter? ->
string module-find-one-arguments ... -> ((module-name . path) ...)
get all names for modules under or at path using module-find-one
procedure: module-find-by-name name search-type load-paths ->
(symbol ...) symbol:exact/prefix/prefix-not-exact (string ...) -> ((symbol ...):module-name ...)
find module names by module name part
procedure: module-find-one path #:load-path #:ignore-content #:ignore-load-path #:guile-modules #:file-content-match ->
string [#:load-path (string ...) #:guile-modules boolean #:ignore-content boolean] -> false/(symbol ...):module-name
setting the right load-path is important because the module name is derived from it.
a file is considered a valid module if:
it exists and is a regular file
the file name extension is \".scm\"
the file contains as the first expression an r6rs library or r7rs define-library form
if \"guile-modules\" is true: the file contains a define-module form
it is in a load path and the module name matches the path under a load path (using %load-paths)
procedure: module-fold proc init module ->
procedure:{name any:value any:init} any (symbol ...) -> any
fold over the exported, bound variables for the given module-name
procedure: module-match-guile-definition a ->
any -> false/list:module-name
matches a guile \"define-module\" form and returns the module name
procedure: module-match-rnrs-definition a ->
any -> false/list:module-name
matches a r6rs or r7rs library definition and returns the module name
procedure: module-name->load-path-and-path a filename-extension load-path c ->
(symbol ...) string (string ...) procedure:{string:load-path string:full-path -> any} -> any
finds the load path under which a possibly partial (prefix) module name is saved.
if no filename-extension is given it will usually only match directories
syntax: module-re-export-module module-name ...
modules must have already been imported
procedure: path->load-path path [load-path] ->
string -> false/path
returns the first found load-path where path can be found.
works for full and relative paths
variable: sph-module-description
procedure: symbol-list->path a [filename-extension] ->
(symbol ...) string -> string
creates a filesystem path string from a module name. module existence is not checked.
filename-extension can be false so that for example directory paths can be created