I’m trying to port a C package to Julia. The C program uses the “tinyexpr” package to parse expressions provided by the user. For example, a bit of input might look like this:
x = 3
y = 4
z = 2 + 3*x - exp(-y)
The x and y variables get redefined over and over as the program runs, and z has to keep up.
It should be much easier to do in Julia than in C, because of Julia’s metaprogramming features. But I don’t want to evaluate these expressions in the context of the Julia program itself. The x and y values in the user’s code should not conflict with variables of the same name in my own Julia code. Is there a way to evaluate expressions in a context that is isolated from the surrounding Julia program?
3 posts - 3 participants