I think I figured it out. It looks like I need to esc() the returned
symbol to avoid hygiene issue in this case.
thanks,
wade
On Thursday, December 18, 2014 7:31:38 AM UTC-5, S Wade wrote:
>
> Hi,
>
> I'm trying to return an expression that contains symbols from a macro and
> I'm seeing odd behavior when the macro is declared in a module vs. when a
> macro is declared outside of a module. An exported macro declared from
> within a module can't resolve symbols from the returned expression when it
> tries to eval.
>
> I'm running julia on a mac compiled from the release-0.3 branch (Version
> 0.3.4-pre+74 (2014-12-16 03:44 UTC)). Here's a minimized example of what
> I'm seeing:
>
> julia> macro xxx(str) symbol(str) end
> julia> module Test export @yyy; macro yyy(str) symbol(str) end end
> julia> using Test
> julia> global x = 10
> 10
> julia> @xxx("x")
> 10
> julia> @yyy("x")
> ERROR: x not defined
>
> I guess that I must be misunderstanding something about hygiene. Any help
> would be appreciated.
>
> thanks,
> wade