I got it to work with:

macro wrapexpr(expr)
  x = :x
  y = :y
  quote
    $(esc(quote ($x, $y) -> $expr end))
  end
end

I think the problem before was that the entire anonymous function has to be 
escaped. I also don't claim to understand hygiene well enough to really 
understand what that means.

Hopefully your pull goes through!


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.
>

Reply via email to