Next: , Up: Loading   [Contents][Index]

5.16.1 Load Function

Function: load program #!optional no-error no-path no-suffix

This function loads the file containing the program called program. First the file is located, then evaluated, i.e., each top-level form is read and evaluated in order.

If program is not an absolute path, each directory named by the variable load-path is searched until the file containing program is found. In each directory two different file names are tried,

  1. program with ‘.jlc’ appended to it. Files with a ‘.jlc’ suffix are usually compiled Lisp files. See Compiled Lisp.

    If it is older than a ‘.jl’ version of the same file (i.e. the source code is newer than the compiled version), a warning is displayed and the ‘.jl’ version is used instead.

  2. program with ‘.jl’ appended, most uncompiled Lisp programs are stored in files with names like this.

Notice that the file program with no modifications is not loaded. If you want it, set no-suffix to non-nil.

Filename can have a leading tilde in Unix, and tar archive is also readable directly. See See File Handlers.

If none of these gives a result the next directory is searched in the same way. When all directories in load-path have been exhausted and the file still has not been found an error is signalled.

Next the file is opened for reading and Lisp forms are read from it one at a time, each form is evaluated before the next form is read. When the end of the file is reached, this function returns true.

The optional arguments to this function are used to modify its behaviour,


When this argument is true no error is signalled if the file can not be located. Instead the function returns false.


The variable load-path is not used, program must point to the file from the current working directory.


When true no ‘.jlc’ or ‘.jl’ suffixes are applied to the program argument when locating the file.

If no Lisp file can be found matching program, then each directory in the variable dl-load-path is searched for a libtool shared library called

Variable: load-filename

Whilst loading a Lisp library, this variable is bound to the name of the file being loaded.

Variable: load-path

A list of strings, each element is the name of a directory which is prefixed to the name of a program when Lisp program files are being searched for.

    ⇒ ("/usr/local/lib/rep/1.0/lisp/"
        "/usr/local/lib/rep/site-lisp/" "")

The element "" refers to the current directory, note that directory names should have an ending ‘/’ (or whatever) so that when concatenated with the name of the file they make a meaningful filename.

Variable: dl-load-path

A list of strings defining all directories to search for shared libraries.

Variable: lisp-lib-directory

The name of the directory in which the standard Lisp files are stored.

    ⇒ "/usr/local/lib/rep/1.0/lisp/"
Variable: after-load-alist

An association list of elements of the format (file forms …). When the library file is loaded, all forms are executed. However, note that file must exactly match the program argument to the load function.

Function: eval-after-load library form

Arrange for form to be evaluated immediately after the Lisp library of library has been read by the load function. Note that library must exactly match the program argument to load.

Next: , Up: Loading   [Contents][Index]