7.5 The Load Facility

7.5.2 Reference pages

*ignore-binary-dependencies* Variable

Syntax:*ignore-binary-dependencies*

The variable*ignore-binary-dependencies* provides a default value for the:ignore-binary-dependencies keyword argument to the functionload. The initial value is nil.

load Function

Syntax:load filename&key :verbose :print :if-does-not-exist :if-source-only :if-source-newer :ignore-binary-dependencies

The functionload reads the file specified by the filename argument and evaluates each form in that file. It returns a non-nil value if the operation is successful.

The filename argument is a pathname, stream, string, or symbol.

If the filename argument specifies a stream,load determines the type of the stream and loads either source code or binary data directly from the stream.

If the filename argument is a pathname that is not fully specified, default values are taken from the value of the Common Lisp variabledefault-pathname-defaults* by using the Common Lisp functionmerge-pathnames.

If the filename argument specifies a pathname that has an explicit type component,load searches for a file that matches the given pathname:

If the filename argument specifies a pathname that does not have an explicit type component,load searches for source files by merging successive elements of*load-source-pathname-types* with the given pathname until it finds a match. It then searches for binary files by merging successive elements of*load-binary-pathname-types* with the given pathname until it finds a match. The file that is loaded is determined as follows:

The following keyword arguments control details of loading a file:

If the value is:load-source, the source file is loaded.

If the value is:query and the functioncompile-file is defined,load asks whether to load the source file or to compile the source file and load the resulting binary file. Ifcompile-file is not defined, the source file is loaded.

If the value is:compile, the source file is compiled and the resulting binary file is loaded.

The default value of:if-source-only is the value of the variable*load-if-source-only*. Its initial value is:load-source.

If the value is:query and the functioncompile-file is defined,load asks whether to load the source file, load the binary file, or compile the source file and load the resulting binary file. If the functioncompile-file is not defined,load asks whether to load the source file or the binary file.

If the value is:load-source, the source file is loaded.

If the value is:load-binary, the binary file is loaded.

If the value is:compile and the functioncompile-file is defined, the source file is compiled and the resulting binary file is loaded. Ifcompile-file is not defined,load asks whether to load the source file or the binary file.

The default value of:if-source-newer is the value of the variable*load-if-source-newer*. Its initial value is:query.

If the value ist, the file is loaded.

If the value isnil, a continuable error is signaled.

If the value is:warn, a warning is issued and the file is loaded.

The default value of:ignore-binary-dependencies is the value of the variable*ignore-binary-dependencies*. Its initial value isnil.

The standard output stream is defined by the value of the Common Lisp variable*standard-output*.

To suppress redefinition warnings, the variable*redefinition-action* must be set tonil. This variable is described in Chapter 6, "Miscellaneous Programming Features".

You can concatenate several binary files into one and load that single file as you would any binary file; the filename must end with the binary extension".xbin" (see Section 2.1.4 of The User's Guide for the binary file extension for your platform).

The keyword arguments:if-source-only,:if-source-newer, and:ignore-binary-dependencies are extensions to Common Lisp.

;;; Assume that the file /test/load-test-file.lisp contains
;;;
;;; 1
;;; (setq a 888)
;;;
> (load "/test/load-test-file")
;;; Loading source file "/test/load-test-file.lisp"
#P"/test/load-test-file.lisp"

> a 888

> (load (setq p (merge-pathnames "/test/load-test-file")) :verbose t) ;;; Loading source file "/test/load-test-file.lisp" #P"/test/load-test-file.lisp"

> (load p :print t) ;;; Loading source file "/test/load-test-file.lisp" 1 888 #P"/test/load-test-file.lisp"

;;; Assume that the current directory contains "tourist.lisp" ;;; and "tourist.lbin" and that "tourist.lisp" is newer than ;;; "tourist.lbin". > *load-if-source-newer* ; The default value is :QUERY. :QUERY

> (load "tourist") Source file "tourist.lisp" is newer than binary file "tourist.lbin". Load Source, Binary, or Compiled source (S, B or C): s ;;; Loading source file "tourist.lisp" #P"/u/r/chkout/test/tourist.lisp"

> (load "tourist") Source file "tourist.lisp" is newer than binary file "tourist.lbin". Load Source, Binary, or Compiled source (S, B or C): b ;;; Loading binary file "tourist.lbin" #P"/u/r/chkout/test/tourist.lbin"

> (load "tourist") Source file "tourist.lisp" is newer than binary file "tourist.lbin". Load Source, Binary, or Compiled source (S, B or C): c ;;; Reading source file "tourist.lisp" ;;; Writing binary file "tourist.lbin" ;;; Loading binary file "tourist.lbin" #P"/u/r/chkout/test/tourist.lbin"

See Also:error, *ignore-binary-dependencies*, *load-if-source-newer*, *load-if-source-only*, *load-binary-pathname-types*, *load-source-pathname-types*; *load-verbose* (in CLtL2)

*load-binary-pathname-types* Variable

Syntax:*load-binary-pathname-types*

The variable*load-binary-pathname-types* determines which pathnames are considered byload to denote binary files. Its value is a list of pathname types.

The value of*load-binary-pathname-types* must be a list in which each element is either a string ornil. The initial value is("lbin").

*load-if-source-newer* Variable

*load-if-source-only* Variable

Syntax:*load-if-source-newer*

Syntax:*load-if-source-only*

These variables provide default values for keyword arguments to the functionload:

*load-source-pathname-types* Variable

Syntax:*load-source-pathname-types*

The variable*load-source-pathname-types* determines which pathnames are considered byload to denote source files. Its value is a list of pathname types.

The value of*load-source-pathname-types* must be a list in which each element is either a string ornil. The initial value is("lisp" NIL).

The functionload can only consider a pathname without an explicit extension as a source file if the variable*load-source-pathname-types* contains the elementnil.

;;; Assume that the current directory contains the source files 
;;; "dragon" and "dragon.lisp".

> *load-source-pathname-types* ("lisp" NIL)

> (load "dragon") ;;; Loading source file "dragon.lisp" #P"/u/r/chkout/test/dragon.lisp"

> (setq *load-source-pathname-types* '(NIL "lisp")) (NIL "lisp")

> (load "dragon") ;;; Loading source file "dragon" #P"/u/r/chkout/test/dragon"

pathname-lessp Function

Syntax:pathname-lessp namestring1 namestring2

The functionpathname-lessp compares two namestrings by using the Common Lisp functionstring-lessp.

See Also:string-lessp (in CLtL2)


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker