Metaprogramming - defining a function

With trivial modifications to my code aobve

body = :(a + q * other_function(d))
other_function(x) = (println("Calling this function from inside"); x^5)
julia> eval(create_function_expr(function_name, sig, variables, body))
foobar (generic function with 1 method)

julia> foobar(1, 2.0, Int32(3))
Calling this function from inside
487.0

Hmm, yes maybe you are just doing it wrong. Without a clear example of what you actually want to do, it is hard to say.

1 Like