An environment is a stack of scopes with the innermost scope on the top.
Support for unique ids for named things.
A named entity.
A scope maps identifiers to entities.
Define i
to be e
in the current scope of env
, raising an error if
the environment is empty.
As for define
, except if i
is already defined in the innermost
scope of env
, define it to be MultipleEntity
instead.
As for define
, except if i
is already defined in the innermost
scope of env
, define it to be MultipleEntity
instead. The entity
e
is only evaluated if needed.
Enter a new empty scope nested within the given environment.
Pretty-print the environment env
.
Say whether i
is defined in any scope of env
.
Say whether i
is defined in an innermost scope of env
(i.e., in the
current scope).
Say whether i
is defined in an outer scope of env
(i.e., not in the
current scope).
Say whether i
is defined in the given scope.
Say whether i
is defined in the current scope of env
.
Leave the outermost scope of the given environment, raising an error if the environment is empty.
Look up i
in env
, returning the mapped Entity if there is one,
otherwise return e
.
Look up i
in env
, returning the mapped Entity if there is one,
otherwise return e
. If local
is true, just search the innermost
scope, otherwise search outwards in all scopes, returning the first
entity found, if any.
A counter to count generated names.
Create a root environment, i.e., one that has a single scope containing the given bindings.
General implementation of environments as stacked scopes. The objects associated with names in environments are of type Entity.