source nlmod.lsp
Module: nlmod
Author: Jeff Ober
Version: 1.1
Location: http://static.artfulcode.net/newlisp/nlmod.lsp
Load modules with dependency processing.
nlmod deals with interdependencies between newLISP modules and files, freeing the programmer from having to add load statements at the top of each of the files an application. Files may be stored in any number of directories, but no two files may share a name (even if they have different extensions).
Files are loaded by their simple name. The path is left off and if the extension is .lsp, it may be left off as well. The default search path is the newLISP modules folder. More may be added using nlmod:push-path and nlmod:append-path. Modules are loaded with nlmod:load-module.
The dependencies file(s) is assigned with nlmod:read-dependencies. The file must contain a list of forms using nlmod:add-deps syntax. See the file dependencies.lsp which contains the dependencies for the Artful Code modules.
Version history
1.1 • added load-modules • read-dependencies may now take a list
1.0 • initial release- § - nlmod:push-path
syntax: (nlmod:push-path str-path)
parameter: str-path - path to add
Inserts a path to the beginning of the search list. Pushes other paths back in the load order by one place.
example:nlmod:paths => '("/usr/share/newlisp/modules") (nlmod:push-path "/home/me/site-lisp") => '("/home/me/site-lisp" "/usr/share/newlisp/modules")- § - nlmod:append-path
syntax: (nlmod:append-path str-path)
parameter: str-path - path to add
Adds a path to the end of the search list. This path will be searched last.
example:nlmod:paths => '("/usr/share/newlisp/modules") (nlmod:append-path "/home/me/site-lisp") => '("/usr/share/newlisp/modules" "/home/me/site-lisp")- § - nlmod:read-dependencies
syntax: (nlmod:read-dependencies str-file)
parameter: str-file - full path to dependencies file
Reads dependencies from a file. Alternately, if str-file is a list, each file will be processed in sequence.
example:(write-file "/home/me/deps.lsp" [text](nlmod:add-deps "foo" '("bar" "baz"))[/text]) (nlmod:read-dependencies "/home/me/deps.lsp")- § - nlmod:add-deps
syntax: (nlmod:add-deps str-module lst-deps)
parameter: str-module - name of the module
parameter: lst-deps - list of module names that str-module depends on
Adds a set of dependencies for str-module. The module is defined as the simple file name, as are the dependencies. Multiple add-deps statements may be saved in a file and read altogether with read-dependencies.
example:(nlmod:add-deps "foo" '("bar" "baz" "bat"))- § - nlmod:load-module
syntax: (nlmod:load-module str-module)
parameter: str-module - module to load
Will attempt to load str-module by trying to find it along the series of listed paths. The path should be left off, and the extension may be omitted if it is .lsp Evaluates true when module is successfully loaded, nil when the module has already been loaded. Throws an error if the module cannot be found.
example:(nlmod:add-deps "foo" '("bar" "bat")) (nlmod:add-deps "bar" '("bat" "baz")) (nlmod:load-module "foo") => loads in this order: baz, bat, bar, foo- § - nlmod:load-modules
syntax: (nlmod:load-modules lst-modules)
parameter: lst-modules - list of modules to load in sequence
load-modules loads each module listed in lst-modules in turn. If one fails, the function stops and throws an error.
- § - nlmod:reload-module
syntax: (nlmod:reload-module str-module [bool-reload-deps?])
parameter: str-module - module to reload
parameter: bool-reload-deps? - switch to reload dependencies as well (optional)
Loads str-module, even if it has already been loaded. If the optional second parameter is non-nil, reloads str-module's dependencies as well.
- ∂ -
Artful Code
generated with newLISP and newLISPdoc