This proposal provides mutable environments for R7RS-large. It's based on this proposal by Pavel Curtis, but he is not responsible for the use I have made of it.
The small language provides four procedures that return global environments for use by eval. They are:
The following procedures allow an application to generate, examine, and mutate environments which can be used like those obtained from the R7RS-small procedures above.
(make-environment environment ...)
Returns a newly allocated mutable environment that has imported into it the bindings of the environments.
(environment? obj)
Returns #t if obj is an environment, and #f otherwise.
(mutable-environment? obj)
Returns #t if obj is a mutable environment, and #f otherwise.
(environment-ref environment symbol)
If symbol is bound as a variable in environment, returns the value bound to it. If symbol is bound as a syntax keyword, returns an implementation-defined object. If symbol is not bound, returns #f.
(environment-bound? environment symbol)
Returns #t if symbol is bound in environment, and #f otherwise.
(environment-set! environment symbol value)
In environment, binds symbol as a variable whose value is value, discarding any existing binding. Returns an unspecified value.
(environment-for-each environment proc)
Invokes proc on each identifier bound in environment whose value comes from a call to environment-set!. Proc is passed the identifier and the value (or an unspecified value if the identifier is bound as a syntax keyword). Note that identifiers imported when the environment was created are not passed to proc unless their values have been changed. Returns an unspecified value.