I should add, I suspect that 'esc' can only be used in a quote block, so I
tried this instead:
macro wrapexpr(expr)
quote
($(esc(x)), $(esc(y))) -> $(esc(expr))
end
end
But get:
ERROR: x not defined
On Wednesday, June 4, 2014 11:44:43 AM UTC-4, David Moon wrote:
>
> I have a pending pull request #6910 to fix macros to behave as you expect,
> but until that gets integrated you will need to use the esc function in
> your macro to tell the macro system that x, y, and expr are in the macro
> caller's context, not the macro definition's context. There is no
> guarantee that my changes will ever be integrated, but with those changes
> you would write:
>
> macro wrapexpr(expr)
> quote
> ($:x, $:y) -> $(expr)
> end
> end
>
> Without my changes I think you would write:
>
> macro wrapexpr(expr)
> x = esc(:x)
> y = esc(:y)
> quote
> ($x, $y) -> $(esc(expr))
> end
> end
>
> but I have not tested it.
>