std-provide - std-require | ![]() ![]() |
(std-provide <module-name>) ; defines a module
(std-require <module-name>) ; loads a module
STD-PROVIDE defines a module. Currently the module name must match the filename (without path and extension) in which the module is defined.
STD-REQUIRE loads a module if it was not previously loaded. It looks for acurrently defined module (e.g. it may look for the module name in *MODULES* if implemented this way) and if it is not defined, it tries to load it from all paths from *MODULE-PATH* or the from the Acad library path.
Take care of cyclic module dependencies!
Recommended style:
Example
;;;MODULE.LSP
;;; START of file: top-level dependencies for module
(std-require 'stdlib)
;;; module-code goes here
;;; END of file: dependencies for module
(std-provide 'module) (std-require "extmodule1") (std-require "extmodule2")
If you require some modules before you provide the module name you are in trouble!
You may do it with the STDLIB for example, but cyclic module dependencies are not resolved, so you may fall into inifinite require loops. to avoid this put the std-provide call before the other the std-require calls.
module-name: string or symbol. Usually the filename of the lisp file in which the module is defined. Just the name without absolute path or extension is needed. Usually case insensitive but OS dependant. This name is passed to std-load if the module was not previously loaded.
A symbol is allowed because lisp is a symbolic language. It's much faster dealing with symbols than with strings.
However if the modulename is longer than 8 characters it is better to define it as string, because of the DOS 8.3 filename restriction and to avoid possible problems. For now I found none, but you knows what will happen in future versions.
ViLL/Visual Lisp converts filenames to uppercase on storing so you would be on the safe side to use uppercase strings or symbols on long filenames.
Not defined.
STD-PROVIDE may add a module-name to the global module list: *MODULES*
It is forbidden to change *MODULES* by hand. STD-PROVIDE and STD-REQUIRE should be enough. And other implementations are possible too.
STD-REQUIRE may load a new module, which may create unpredictable side-effects on top-level calls, while evaluating the contents of the lisp file.
(std-require 'STDINIT)
Defined in STDMODUL