This procedure returns a specifier for the environment that results by starting with an empty environment and then importing each
list
, considered as animport-set
, into it. The bindings of the environment represented by the specifier are immutable, as is the environment itself. See theeval
function for examples.
Procedure: null-environment
version
This procedure returns an environment that contains no variable bindings, but contains (syntactic) bindings for all the syntactic keywords.
The effect of assigning to a variable in this environment (such as
let
) is undefined.
Procedure: scheme-report-environment
version
The
version
must be an exact non-negative inetger corresponding to a version of one of the Revisedversion
Reports on Scheme. The procedure returns an environment that contains exactly the set of bindings specified in the corresponding report.This implementation supports
version
that is 4 or 5.The effect of assigning to a variable in this environment (such as
car
) is undefined.
Procedure: interaction-environment
This procedure return an environment that contains implementation-defined bindings, as well as top-level user bindings.
Procedure: environment-bound?
environment
symbol
Return true
#t
if there is a binding forsymbol
inenvironment
; otherwise returns#f
.
Procedure: environment-fold
environment
proc
init
Call
proc
for each key in theenvironment
, which may be any argument toeval
, such as(interaction-environment)
or a call to theenvironment
procedure. Theproc
is called with two arguments: The binding’s key, and an accumulator value. Theinit
is the initial accumulator value; the result returned byproc
is used for subsequent accumulator values. The value returned byenvironment-fold
is the final acumulator value.A key is normally a symbol, but can also be a
KeyPair
object (a pair of a symbol and a property symbol used to implement Common Lisp-style property lists).(environment-fold (environment '(scheme write)) cons '()) ⇒ (display write-shared write write-simple)To get all the predefined bindings use
(environment '(kawa base))
.
Syntax: fluid-let
((variable
init
) ...
) body
...
Evaluate the
init
expressions. Then modify the dynamic bindings for thevariables
to the values of theinit
expressions, and evaluate thebody
expressions. Return the result of the last expression inbody
. Before returning, restore the original bindings. The temporary bindings are only visible in the current thread, and its descendent threads.
If
node
is specified, returns the base-URI property of thenode
. If thenode
does not have the base-URI property, returns#f
. (The XQuery version returns the empty sequence in that case.)In the zero-argument case, returns the "base URI" of the current context. By default the base URI is the current working directory (as a URL). While a source file is
load
ed, the base URI is temporarily set to the URL of the document.
Procedure: eval
expression
[environment
]
This procedure evaluates
expression
in the environment indicated byenvironment
. The default forenvironment
is the result of(interaction-environment)
.(eval ’(* 7 3) (environment '(scheme base))) ⇒ 21 (let ((f (eval '(lambda (f x) (f x x)) (null-environment 5)))) (f + 10)) ⇒ 20 (eval '(define foo 32) (environment '(scheme base))) ⇒ error is signaled
Procedure: load
path
[environment
]
Procedure: load-relative
path
[environment
]
The
path
can be an (absolute) URL or a filename of a source file, which is read and evaluated line-by-line. Thepath
can also be a fully-qualified class name. (Mostly acts like the-f
command-line option, but with different error handling.) Sinceload
is a run-time function it doesn’t know about the enclosing lexical environment, and the latter can’t know about definitions introduced byload
. For those reasons it is highly recommended that you use instead userequire
orinclude
.Evaluation is done in the specified
environment
, which defauls to result of(interaction-environment)
.The
load-relative
procedure is likeload
, except thatpath
is a URI that is relative to the context’s current base URI.