Go to the first, previous, next, last section, table of contents.


Evaluation

This chapter describes Guile functions that are concerned with loading and evaluating Scheme code at run time. R4RS Scheme, because of strong differences in opinion among implementors, only provides a load function. There are many useful programs that are difficult or impossible to write without more powerful evaluation procedures, so we have provided some.

[FIXME: This needs some more text on the difference between procedures, macros and memoizing macros. Also, any definitions listed here should be double-checked by someone who knows what's going on. Ask Mikael, Jim or Aubrey for help. -twp]

primitive: procedure-documentation proc
Return the documentation string associated with proc. By convention, if a procedure contains more than one expression and the first expression is a string constant, that string is assumed to contain documentation for that procedure.

primitive: procedure->syntax proc
[FIXME: Get documentation from SCM/SLIB.]

primitive: procedure->macro proc
[FIXME: Get documentation from SCM/SLIB.]

primitive: procedure->memoizing-macro proc
[FIXME: Get documentation from SCM/SLIB.]

primitive: macro? obj
Return #t if obj is a regular macro, a memoizing macro or a syntax transformer.

primitive: macro-type obj
Return one of the symbols syntax, macro or macro!, depending on whether obj is a syntax tranformer, a regular macro, or a memoizing macro, respectively. If obj is not a macro, #f is returned.

primitive: macro-name

primitive: macro-transformer

primitive: promise? obj
Return true if obj is a promise, i.e. a delayed computation (see section `Delayed evaluation' in The Revised^4 Report on Scheme).

primitive: copy-tree obj
Recursively copy the data tree that is bound to obj, and return a pointer to the new data structure. copy-tree recurses down the contents of both pairs and vectors (since both cons cells and vector cells may point to arbitrary objects), and stops recursing when it hits any other object.

primitive: eval exp
Evaluate exp, a list representing a Scheme expression, in the top-level environment.

primitive: eval2 exp lookup
Evaluate exp, a Scheme expression, in the environment designated by lookup, a symbol-lookup function. (eval exp) is equivalent to (eval2 exp *top-level-lookup-closure*).

primitive: local-eval! exp [env]
Evaluate exp in its environment. If env is supplied, it is the environment in which to evaluate exp. Otherwise, exp must be a memoized code object (in which case, its environment is implicit).

primitive: defined? sym
Return #t if sym is defined in the top-level environment.

primitive: read-and-eval! [port]
Read a form from port (standard input by default), and evaluate it (memoizing it in the process) in the top-level environment. If no data is left to be read from port, an end-of-file error is signalled.

primitive: primitive-load file
Load file and evaluate its contents in the top-level environment. The load paths are not searched; file 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 documentation for %load-hook later in this section.

primitive: primitive-load-path file
Search %load-path for file and load it into the top-level environment. If file is a relative pathname and is not found in the list of search paths, an error is signalled.

primitive: %search-load-path file
Search %load-path for file, which must be readable by the current user. If file 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.

Variable: %load-hook
A procedure to be run whenever primitive-load is called. If this procedure is defined, it will be called with the filename argument that was passed to primitive-load.

(define %load-hook (lambda (file)
                     (display "Loading ")
                     (display file)
                     (write-line "...."))) => undefined
(load-from-path "foo.scm")
-| Loading /usr/local/share/guile/site/foo.scm....

Variable: %load-extensions
A list of default file extensions for files containing Scheme code. %search-load-path tries each of these extensions when looking for a file to load. By default, %load-extensions is bound to the list ("" ".scm").


Go to the first, previous, next, last section, table of contents.