10.6 Loading Modules

Two convenient procedures are available for loading modules. Various facilities described in this manual are actually in loadable modules and their documentation notes that they must be loaded. Loadable modules typically exist as FASL files .B files see the section on the compiler for information on producing FASL files.

(load [FILE:{string, id}]): nil macro
For each argument FILE, an attempt is made to locate a corresponding file. If a file is found then it will be loaded by a call on an appropriate function. A full file name is constructed by using the directory specifications in loaddirectories* and the extensions in loadextensions*. The strings from each list are used in a left to right order, for a given string from loaddirectories* each extension from loadextensions* is used. More information about loaddirectories* and loadextensions* can be found below.

While the file is being loaded *usermode will be set to nil. If a file cannot be found the call on load will be aborted.

    ⋆⋆⋆⋆⋆ ‘FILE' load module not found

If either *verboseload or *printloadnames is non-nil then

    ⋆⋆⋆ loading FULL-NAME

is printed just prior to loading the file. Once a file has been loaded the message

    ⋆⋆⋆ FILE loaded

will be printed if the *verboseload is non-nil. In addition, the name FILE is added to the list referenced by options*. If an attempt is made to load a file which has been partially loaded then

  ⋆⋆⋆ Warning: Load of FILE previously requested, but incomplete.

will be printed. If FILE is found to be in options* then the attempt to load FILE will be ignored.

    ⋆⋆⋆ FILE already loaded

Note that memq is used to determine if FILE is in options*. Therefore when you use string arguments for loading files, although identical names for ids refer to the same object, identical names for strings refer to different objects.

(reload [FILE:{string,id}]): nil macro
Reload is very similar to load. The difference between the two is that for each name FILE, the first occurance of FILE in options* will be removed before attempting to load the file.

(imports FILES:list): nil expr
This function is also used to load modules. If imports is invoked as another module is being loaded, then the modules specified by FILES will not be loaded until the loading of the current module is complete. Otherwise imports is identical to load.

loaddirectories* = [Initially: list] global
References a list of strings to append to the front of file names passed as arguments to load, reload, and imports.

loadextensions* = [Initially: association-list] global
References the a-list ((".b" . faslin) (".lap" . lapin))

The car of each pair is a string which represents an extension to append to the end of the file names passed as arguments to load, reload, and imports. The cdr is a function appropriate for loading a file of a particular extension. For example, a file whose extension is B is loaded with the function faslin.

options* = [Initially: nil] global
Once a file corresponding to an argument FILE to either load, reload, or imports has been loaded, FILE will be added to the list referenced by options*. An attempt to load a file by applying load or imports will be aborted if FILE is found in options*. Reload removes the first occurance of FILE from options* before passing its argument to load.

*verboseload = [Initially: nil] switch
If non-nil, a message is displayed when a request is made to load a file which has already been loaded, when a file is about to be loaded, and when the loading of a file is complete. Since *redefmsg is set to the value of *verboseload, a non-nil value will also cause a message to be printed whenever a function is redefined during a load.

*printloadnames = [Initially: nil] switch
If non-nil, a message is printed when a file is about to be loaded.