I’m trying to implement the following scenario: based on some configuration, I want to build an expression which essentially defines a function:
function build(config::String) :(function p() println($config) end) # or :(() -> println($config)) end ex = build("test")
And then pass the compiled function to another method:
function test(f::Function) f() end test(eval(ex)) # prints "test"
eval however has a side effect of introducing function
p() (or if it has no name, then anonymous function) in the current global scope. Does anybody know how to achieve the same goal while not introducing additional definitions to the global scope, like
const f = compile(ex) f() # prints "test" methods(p) # p not defined