Reputation: 107
For languages that allow for meta-programming is it possible to parse and evaluate a string locally? For example within a function? I'm trying to do this in Julia currently but also curious about the ability of other languages?
Upvotes: 0
Views: 520
Reputation: 443
Is this what you mean?
function foo()
println("Calling foo")
end
function main(functionName)
functionCall = @eval $(Symbol(functionName))
functionCall()
end
Calling main
with the function name "foo"
string passed evaluates foo
julia> main("foo")
Calling foo
Upvotes: 2