riff-lang / riff

The Riff programming language
https://riff.cx
BSD Zero Clause License
23 stars 1 forks source link

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

Open darrylabbate opened 1 year ago

darrylabbate commented 1 year ago

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 commented 8 months ago

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