This site is a static rendering of the Trac instance that was used by R7RS-WG1 for its work on R7RS-small (PDF), which was ratified in 2013. For more information, see Home.

Source for wiki MutableEnvironmentsCurtisCowan version 2

author

cowan

comment


    

ipnr

198.185.18.207

name

MutableEnvironmentsCurtisCowan

readonly

0

text

This proposal provides mutable environments for R7RS-large.  It's based on [http://groups.csail.mit.edu/mac/ftpdir/scheme-mail/HTML/rrrs-1988/msg00139.html this proposal by Pavel Curtis], but he is not responsible for the use I have made of it.

== Introduction ==

The small language provides four procedures that return global environment specifiers for use by `eval`.  They are:

* `environment`, which returns an immutable environment specifier when passed on zero or more import-specs which contains the bindings made available by those import specs

* `scheme-report-environment`, which when passed the argument `5` returns a specifier for a copy of the R5RS environment, which may or may not be mutable

* `null-environment`, which when passed the argument `5` returns a specifier for a copy of the R5RS environment containing syntax keywords only, which may or may not be mutable

* `interaction-environment`, which returns a mutable environment specifier containing implementation-defined bindings, including at least those exported by the base library

== Procedures ==

The following procedures allow an application to generate, examine, and mutate environment specifiers which can be used like those obtained from the R7RS-small procedures above.

`(make-environment `''environment'' ...`)`

Returns a newly allocated mutable environment specifier that has imported into it the bindings of the ''environments''.

`(environment? `''obj''`)`

Returns `#t` if ''obj'' is an environment specifier, and `#f` otherwise.

`(mutable-environment? `''obj''`)`

Returns `#t` if ''obj'' is a mutable environment specifier, and `#f` otherwise.

`(environment-ref `''environment symbol''`)`

If ''symbol'' is bound as a variable in the environment specified by ''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 the environment specified by ''environment'', and `#f` otherwise.

`(environment-set! `''environment symbol value''`)`

In the environment specified by ''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 the environment specified by ''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.

time

2013-01-28 09:51:43

version

2