Next: Delayed Evaluation, Previous: Fly Evaluation, Up: Read/Load/Eval
Load filename and evaluate its contents in the top-level environment. The load paths are not searched.
reader if provided should be either
#f
, or a procedure with the signature(lambda (port) ...)
which reads the next expression from port. If reader is#f
or absent, Guile's built-inread
procedure is used (see Scheme Read).The reader argument takes effect by setting the value of the
current-reader
fluid (see below) before loading the file, and restoring its previous value when loading is complete. The Scheme code inside filename can itself change the current reader procedure on the fly by settingcurrent-reader
fluid.If the variable
%load-hook
is defined, it should be bound to a procedure that will be called before any code is loaded. See documentation for%load-hook
later in this section.
Similar to
load
, but searches for filename in the load paths.
Load the file named filename and evaluate its contents in the top-level environment. The load paths are not searched; filename must either be a full pathname or be a pathname relative to the current directory. If the variable
%load-hook
is defined, it should be bound to a procedure that will be called before any code is loaded. See the documentation for%load-hook
later in this section.
Search
%load-path
for the file named filename and load it into the top-level environment. If filename is a relative pathname and is not found in the list of search paths, an error is signalled.
Search
%load-path
for the file named filename, which must be readable by the current user. If filename is found in the list of paths to search or is an absolute pathname, return its full pathname. Otherwise, return#f
. Filenames may have any of the optional extensions in the%load-extensions
list;%search-load-path
will try each extension automatically.
current-reader
holds the read procedure that is currently being used by the above loading procedures to read expressions (from the file that they are loading).current-reader
is a fluid, so it has an independent value in each dynamic root and should be read and set usingfluid-ref
andfluid-set!
(see Fluids and Dynamic States).
A procedure to be called
(%load-hook
filename)
whenever a file is loaded, or#f
for no such call.%load-hook
is used by all of the above loading functions (load
,load-path
,primitive-load
andprimitive-load-path
).For example an application can set this to show what's loaded,
(set! %load-hook (lambda (filename) (format #t "Loading ~a ...\n" filename))) (load-from-path "foo.scm") -| Loading /usr/local/share/guile/site/foo.scm ...