See
http://docs.julialang.org/en/release-0.3/manual/metaprogramming/#interpolation
On Mar 18, 2015 8:08 AM, "Abe Schneider" <abe.schnei...@gmail.com> wrote:

> If I do something simple like:
>
> macro test()
>  :(parsefloat("3.1459"))
> end
>
> @test()
>
> # 3.1459
>
> everything works as expected. However, if I try this instead:
>
> macro test2(ex)
>  ex
> end
>
> @test2(:(parsefloat("3.1459")))
>
> # :(parsefloat("3.1459"))
>
>
> Not what I expected, but it makes sense what's happening:
>
> macroexpand(:(@test(:(parsefloat("3.1459")))))
>
> # :($(Expr(:copyast, :(:(parsefloat("3.1459"))))))
>
> So, anything I pass to the macro is automatically quoted. Obviously if I
> just do:
>
> @test2(parsefloat("3.1459"))
>
> it will work. However, the use-case I'm trying to deal with is that I have
> an Expr that I would like inserted into the AST. Besides being frowned on,
> I can't eval, due to not wanting things to be evaluated in global space.
>
> Is there some way I can unquote the expression in the macro for test2?
>

Reply via email to