You want to pass the symbol into the macro or convert before the quote
block:

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

Or you can just add some parens:

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

You want to convert from string to symbol *in macro context*, not at run
time. That way the code a run-time has a symbol that it will understand as
a function call.

-- Leah

On Fri, Jul 3, 2015 at 3:26 PM, <[email protected]> wrote:

> I meant inside the macro.
>
> Le vendredi 3 juillet 2015 15:26:01 UTC+2, [email protected] a écrit :
>>
>> Ok, it seems eval(parse($name)) inside the function does the trick...
>>
>

Reply via email to