mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-20 02:30:23 +02:00
* api-evaluation.texi (Loading): Document custom reader.
* boot-9.scm (load-module): Support an optional custom reader arg, implemented by passing on to r4rs's load. * r4rs.scm (load): Support an optional custom reader arg, implemented by passing on to primitive-load. * load.c (the_reader, the_reader_fluid_num): New. (scm_primitive_load): Support custom reader. (scm_init_load): Init the_reader and the_reader_fluid_num; export the_reader as `current-reader'.
This commit is contained in:
parent
2824f4dca1
commit
ec3a8ace63
7 changed files with 78 additions and 16 deletions
|
@ -1,3 +1,7 @@
|
|||
2005-12-14 Neil Jerram <neil@ossau.uklinux.net>
|
||||
|
||||
* api-evaluation.texi (Loading): Document custom reader.
|
||||
|
||||
2005-12-06 Marius Vollmer <mvo@zagadka.de>
|
||||
|
||||
* api-init.texi, api-scheduling.texi, libguile-concepts.texi:
|
||||
|
|
|
@ -409,12 +409,24 @@ the current module.
|
|||
@subsection Loading Scheme Code from File
|
||||
|
||||
@rnindex load
|
||||
@deffn {Scheme Procedure} load filename
|
||||
@deffn {Scheme Procedure} load filename [reader]
|
||||
Load @var{filename} and evaluate its contents in the top-level
|
||||
environment. The load paths are not searched. If the variable
|
||||
@code{%load-hook} is defined, it should be bound to a procedure that
|
||||
will be called before any code is loaded. See documentation for
|
||||
@code{%load-hook} later in this section.
|
||||
environment. The load paths are not searched.
|
||||
|
||||
@var{reader} if provided should be either @code{#f}, or a procedure with
|
||||
the signature @code{(lambda (port) @dots{})} which reads the next
|
||||
expression from @var{port}. If @var{reader} is @code{#f} or absent,
|
||||
Guile's built-in @code{read} procedure is used (@pxref{Scheme Read}).
|
||||
|
||||
The @var{reader} argument takes effect by setting the value of the
|
||||
@code{current-reader} fluid (see below) before loading the file, and
|
||||
restoring its previous value when loading is complete. The Scheme code
|
||||
inside @var{filename} can itself change the current reader procedure on
|
||||
the fly by setting @code{current-reader} fluid.
|
||||
|
||||
If the variable @code{%load-hook} is defined, it should be bound to a
|
||||
procedure that will be called before any code is loaded. See
|
||||
documentation for @code{%load-hook} later in this section.
|
||||
@end deffn
|
||||
|
||||
@deffn {Scheme Procedure} load-from-path filename
|
||||
|
@ -452,6 +464,15 @@ in the @code{%load-extensions} list; @code{%search-load-path}
|
|||
will try each extension automatically.
|
||||
@end deffn
|
||||
|
||||
@defvar current-reader
|
||||
@code{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). @code{current-reader} is a fluid, so it has an
|
||||
independent value in each dynamic root and should be read and set using
|
||||
@code{fluid-ref} and @code{fluid-set!} (@pxref{Fluids and Dynamic
|
||||
States}).
|
||||
@end defvar
|
||||
|
||||
@defvar %load-hook
|
||||
A procedure to be called @code{(%load-hook @var{filename})} whenever a
|
||||
file is loaded, or @code{#f} for no such call. @code{%load-hook} is
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue