7.5 The Load Facility
Syntax:*ignore-binary-dependencies*
*ignore-binary-dependencies*
provides a default value for the:ignore-binary-dependencies
keyword argument to the functionload
. The initial value is nil
.
load
filename&key :verbose :print :if-does-not-exist :if-source-only :if-source-newer :ignore-binary-dependencies
load
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.
load
determines the type of the stream and loads either source code or binary data directly from the stream.
default-pathname-defaults*
by using the Common Lisp functionmerge-pathnames
.
load
searches for a file that matches the given pathname:*load-binary-pathname-types*
, the file is loaded as a binary file.*load-binary-pathname-types*
, the file is loaded as a source file.load
signals a continuable error and prompts for a new filename.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:load
signals a continuable error and prompts for a new filename by default.:if-source-only
keyword argument determines whether the source file is loaded or compiled.:if-source-newer
argument determines which file is loaded.:verbose
argument is non-nil
,load
prints information about its progress on the standard output. The default value of:verbose
is the value of the Common Lisp variable*load-verbose*
. Its initial value ist
.:print
argument is non-nil
,load
prints the value of each expression that is loaded to the standard output stream. The default value of this argument isnil
.:if-does-not-exist
argument controls what happens if the specified file does not exist. The Common Lisp functionopen
is called with the:if-does-not-exist
argument bound to this value, which can be either:error
(signal an error) ornil
(returnnil
from the function load
). The default value is:error
.:if-source-only
argument controls what happens when only a source file exists.:load-source
, the source file is loaded.
: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.
:compile
, the source file is compiled and the resulting binary file is loaded.
:if-source-only
is the value of the variable*load-if-source-only*
. Its initial value is:load-source
.
:if-source-newer
argument controls what happens when both a source file and a binary file exist for the specified filename argument and the source is newer than the binary::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.
:load-source
, the source file is loaded.
:load-binary
, the binary file is loaded.
: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.
:if-source-newer
is the value of the variable*load-if-source-newer*
. Its initial value is:query
.
:ignore-binary-dependencies
argument controls what happens when a specified binary file that has been compiled for a particular run-time feature is loaded on a machine that does not have the correct architecture:t
, the file is loaded.
nil
, a continuable error is signaled.
:warn
, a warning is issued and the file is loaded.
:ignore-binary-dependencies
is the value of the variable*ignore-binary-dependencies*
. Its initial value isnil
.
*standard-output*
.
*redefinition-action*
must be set tonil
. This variable is described in Chapter 6, "Miscellaneous Programming Features".
".xbin"
(see Section 2.1.4 of The User's Guide for the binary file extension for your platform).
: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"
error
, *ignore-binary-dependencies*
, *load-if-source-newer*
, *load-if-source-only*
, *load-binary-pathname-types*
, *load-source-pathname-types*
; *load-verbose*
(in CLtL2)
Syntax:*load-binary-pathname-types*
*load-binary-pathname-types*
determines which pathnames are considered byload
to denote binary files. Its value is a list of pathname types.
*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-only* Variable
Syntax:*load-if-source-newer*
Syntax:*load-if-source-only*
load
:*load-if-source-newer*
provides a default value for the:if-source-newer
keyword argument. The initial value is:query
.*load-if-source-only*
provides a default value for the:if-source-only
keyword argument. The initial value is:load-source
. Syntax:*load-source-pathname-types*
*load-source-pathname-types*
determines which pathnames are considered byload
to denote source files. Its value is a list of pathname types.
*load-source-pathname-types*
must be a list in which each element is either a string ornil
. The initial value is("lisp" NIL)
.
load
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".pathname-lessp Function> *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
namestring1 namestring2
pathname-lessp
compares two namestrings by using the Common Lisp functionstring-lessp
.
string-lessp
(in CLtL2)
Generated with Harlequin WebMaker