Hi everyone,

Here's a quite simple code:

macro create_function(name::String)
    return quote
        (x) -> symbol($name)(x) + 7
    end
end

f = (x) -> 2 * x
g = @create_function("f")
println(g(3.0))

I create a macro to construct a function from another one. The problem is 
that symbol($name) is considered as, well, what it is, a symbol, and not a 
function. Hence the following error that I get when I run the code:

ERROR: type: anonymous: in apply, expected Function, got Symbol

Would there be a way to make this piece of code work, what would be perfect 
would be someting like:

function_call(symbol("function_name"),arg)

Thanks a lot,

Reply via email to