Skip to content

Support for transient variables #4

Open
@karnkaul

Description

@karnkaul

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.)
  • 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 child Env 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 child Envs into distinct (related) types; leverage inheritance for code reuse.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions