Open
Description
It would be useful to be able to contextualize - ie, make available as defined constants - certain variables for specific evaluations.
A few viable approaches:
- A new RAII type that represents a constant defined in an
Env
, "undefining" it on destruction.- Gotchas: lifetime and dangling references. (Since the type would need to store a reference to
Env
.)
- Gotchas: lifetime and dangling references. (Since the type would need to store a reference to
Env
storing a pointer to a parent, delegating symbol lookup to it if not found in its own table. The transient variables would be defined in a childEnv
which would be used for desired evaluations.- Gotchas: while root
Env
should define builtins in its constructor, child ones shouldn't. Solution: separate root and childEnv
s into distinct (related) types; leverage inheritance for code reuse.
- Gotchas: while root