Next: REPL Environment, Previous: Environment Operations, Up: Environments
The user-initial-environment
is where the top-level
read-eval-print (REP) loop evaluates expressions and binds
definitions. It is a child of system-global-environment
, which
is where all of the Scheme system definitions are bound. All of the
bindings in system-global-environment
are available when the
current environment is user-initial-environment
. However, any
new bindings that you create in the REP loop (with
define
forms or by loading files containing define
forms)
occur in user-initial-environment
.
The variable
system-global-environment
is bound to the distinguished environment that's the ancestor of most other environments (except for those created bymake-root-top-level-environment
). It is the parent environment ofuser-initial-environment
. Primitives, system procedures, and most syntactic keywords are bound (and sometimes closed) in this environment.
The variable
user-initial-environment
is bound to the default environment in which typed expressions are evaluated by the top-level REP loop.Although all bindings in
system-global-environment
are visible to the REP loop, definitions that are typed at, or loaded by, the REP loop occur in theuser-initial-environment
. This is partly a safety measure: if you enter a definition that happens to have the same name as a critical system procedure, your definition will be visible only to the procedures you define in theuser-initial-environment
; the MIT/GNU Scheme system procedures, which are defined insystem-global-environment
, will continue to see the original definition.