Previous: Restarting, Up: REPL
Every REPL has a current environment, which is the place
where expressions are evaluated and definitions are stored. When Scheme
is started, this environment is the value of the variable
user-initial-environment
. There are a number of other
environments in the system, for example
system-global-environment
, where the runtime system's bindings
are stored.
You can get the current REPL environment by evaluating
(nearest-repl/environment)
There are several other ways to obtain environments. For example, if you have a procedure object, you can get a pointer to the environment in which it was closed by evaluating
(procedure-environment procedure)
Here is the procedure that changes the REPL's environment:
Changes the current REPL environment to be environment (
ge
stands for “Goto Environment”). Environment is allowed to be a procedure as well as an environment object. If it is a procedure, then the closing environment of that procedure is used in its place.
This procedure is useful for finding out which environment you are in (
pe
stands for “Print Environment”). If the current REPL environment belongs to a package, thenpe
returns the package name (a list of symbols). If the current REPL environment does not belong to a package then the environment is returned.