Warning: This is the manual of the legacy Guile 2.2 series. You may want to read the manual of the current stable series instead.
Next: Load Paths, Previous: Compilation, Up: Read/Load/Eval/Compile [Contents][Index]
Load filename and evaluate its contents in the top-level environment.
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-in read
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 setting current-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.
Load the compiled file named filename.
Compiling a source file (see Read/Load/Eval/Compile) and then
calling load-compiled
on the resulting file is equivalent to
calling load
on the source file.
Load the file named filename and evaluate its contents in the
top-level environment. 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.
scm_primitive_load
, but taking a C string instead of an
SCM
.
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 using
fluid-ref
and fluid-set!
(see Fluids and Dynamic States).
Changing current-reader
is typically useful to introduce local
syntactic changes, such that code following the fluid-set!
call
is read using the newly installed reader. The current-reader
change should take place at evaluation time when the code is evaluated,
or at compilation time when the code is compiled:
(eval-when (compile eval) (fluid-set! current-reader my-own-reader))
The eval-when
form above ensures that the current-reader
change occurs at the right time.
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 loading functions (load
and
primitive-load
, and load-from-path
and
primitive-load-path
documented in the next section).
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 ...
Return the current-load-port.
The load port is used internally by primitive-load
.
Next: Load Paths, Previous: Compilation, Up: Read/Load/Eval/Compile [Contents][Index]