Given the following function,
function floop(exp)
a = 5
b = 10
ex = Expr(:call, :+, 1, exp);
return eval(ex);
end
if I then run
floop(Symbol("b"))
I get an error saying that b
is not defined. Why does this not work? How can I make this work?
One of the key things that lets Julia be fast is that eval always runs in the global scope. This means it can never refer to local variables.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With