Larceny's top-level environments are implemented using first-class environment data structures. Environments can be created and manipulated by user code and are occasionally useful to isolate computations or provide restricted namespaces.
(make-environment name) => env
Make-environment creates a new environment with the given name, a string.
(environment? obj) => bool
Returns #T iff obj is an environment.
(environment-name env) => name
Returns the name that was given to make-environment.
(environment-get-cell env id) => cell
Returns the cell for the variable id in environment env. Signals an error if id denotes a macro in env.
(environment-variables env) => variables
Returns a list of the names of variables that are bound in env.
(environment-variable? env id) => bool
Returns #T if id is a variable in env.
(environment-get env id) => obj
Returns the value of id in env. Signals an error if id does not denote a variable with a defined value in env.
(environment-set! env id obj)
Stores obj in the location denoted by id in the environment represented by env. If id denotes a macro in env then the macro definition is removed.
(environment-macros env) => macros
Returns a list of the names of macros defined in env.
(environment-macro? env id) => macro
Returns #T if id is a macro in env.
(environment-get-macro env id) => macro
Returns the macro associated with id in env. Signals an error if id does not denote a macro in env.
(environment-set-macro! env id macro)
Changes the macro associated with id in env to be macro. If id denotes a variable in env then the variable is removed.
(environment-copy env [name]) => env
Returns a copy of the environment env, giving the new environment the name name if it is specified. The new environment has the same macros and variables as env, but the variables are all bound to new locations.
(environment-syntax-environment env) => syntaxenv
Returns the syntactic environment of env. Generally this is of no use unless you're working with the Twobit internals.
The value of this parameter is the current interaction environment, which is used to look up global variables and syntax definitions in the read-eval-print loop as well as in eval and load when those procedures are called without arguments.
(null-environment version) => env
(scheme-report-environment version) => env
These are specified as for the R5RS, and version may be 4 or 5.
Based in part on Extracting heuristic information from environments, authored by Will Clinger and sent to rrrs-authors on 09 May 1996.