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

eval() should be able to resolve local variables #65

Open
darrylabbate opened this issue Dec 30, 2022 · 1 comment
Open

eval() should be able to resolve local variables #65

darrylabbate opened this issue Dec 30, 2022 · 1 comment
Labels
builtin Built-in functions or variables compiler Compiler/parser experimental Purely experimental ideas (for now) feature New feature or request

Comments

@darrylabbate
Copy link
Member

darrylabbate commented Dec 30, 2022

For comparison, Python's eval() does have access to locals; Lua's load() does not.

Obviously this is a side-effect of how locals are compiled. It's not possible for eval() to know the identifiers of any corresponding in-scope locals since it's thrown away at compile-time. And when eval() calls riff_compile(), a fresh riff_parser is initialized. Even if a single riff_parser was used, it obviously doesn't necessarily mean existing locals would be visible since riff_parser.locals is effectively a stack.

@darrylabbate darrylabbate added bug Something isn't working builtin Built-in functions or variables compiler Compiler/parser labels Dec 30, 2022
@darrylabbate darrylabbate added this to the Riff 0.4 milestone Dec 30, 2022
@darrylabbate darrylabbate added documentation Improvements or additions to documentation feature New feature or request experimental Purely experimental ideas (for now) and removed bug Something isn't working labels Dec 30, 2022
@darrylabbate darrylabbate removed this from the Riff 0.4 milestone Dec 30, 2022
@darrylabbate darrylabbate changed the title eval() can't resolve variables in local scope eval() should be able to resolve local variables Dec 30, 2022
@darrylabbate darrylabbate removed the documentation Improvements or additions to documentation label Feb 15, 2023
@darrylabbate
Copy link
Member Author

Probably makes sense to implement #22 first and see if the methodolgy can be applied to interpolated string expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
builtin Built-in functions or variables compiler Compiler/parser experimental Purely experimental ideas (for now) feature New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant