Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Expression parser

$
0
0

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

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles