macroexpand() might be useful.

The distinction between QuoteNode and Expr(:quote, sym) is often a gotcha.

--Tim

On Saturday, October 17, 2015 08:45:06 AM Matt wrote:
> I thought
> @example a + :b
> passed the expression  :(a + :b) to the internal body of the macro.
> 
> But it's not the case:
> 
> If I define
> macro example(expr)
>    @show expr
>    @show dump(expr)
> end
> 
> Calling @example a + :b prints
> 
> expr = :(a + :b)
> Expr
> 
>   head: Symbol call
> 
>   args: Array(Any,(3,))
> 
>     1: Symbol +
> 
>     2: Symbol a
> 
>     3: Expr
> 
>       head: Symbol quote
> 
>       args: Array(Any,(1,))
> 
>         1: Symbol b
> 
>       typ: Any
> 
>   typ: Any
> 
> 
> while  dump(:(a + :b)) prints
> 
> Expr
> 
>   head: Symbol call
> 
>   args: Array(Any,(3,))
> 
>     1: Symbol +
> 
>     2: Symbol a
> 
>     3: QuoteNode
> 
>       value: Symbol b
> 
>   typ: Any
> 
> 
> So although the expression passed to example prints like :(a + :b), it is
> not :(a+ :b).
> 
> I'm not sure why this is the case.
> 
> Is there a way to create, from any expression, the exact expression passed
> in a body of macro?

Reply via email to