Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for transient variables #4

Open
karnkaul opened this issue Oct 6, 2023 · 0 comments
Open

Support for transient variables #4

karnkaul opened this issue Oct 6, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@karnkaul
Copy link
Member

karnkaul commented Oct 6, 2023

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.
@karnkaul karnkaul added the enhancement New feature or request label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant