Environments

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.

Procedure make-environment

(make-environment name) => env

Make-environment creates a new environment with the given name, a string.

Procedure environment?

(environment? obj) => bool

Returns #T iff obj is an environment.

Procedure environment-name

(environment-name env) => name

Returns the name that was given to make-environment.

Procedure environment-get-cell

(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.

Procedure environment-variables

(environment-variables env) => variables

Returns a list of the names of variables that are bound in env.

Procedure environment-variable?

(environment-variable? env id) => bool

Returns #T if id is a variable in env.

Procedure environment-get

(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.

Procedure environment-set!

(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.

Procedure environment-macros

(environment-macros env) => macros

Returns a list of the names of macros defined in env.

Procedure environment-macro?

(environment-macro? env id) => macro

Returns #T if id is a macro in env.

Procedure environment-get-macro

(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.

Procedure environment-set-macro!

(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.

Procedure environment-copy

(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.

Procedure environment-syntax-environment

(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.

Parameter interaction-environment

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.

Procedures null-environment and scheme-report-environment

(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.


$Id: environ.html,v 1.8 2000/09/22 21:30:23 lth Exp $
larceny@ccs.neu.edu