Re: [julia-users] Macro hygiene issue
Thank you, that solved it. On Wed, Mar 2, 2016 at 10:54 AM, Yichao Yu wrote: > On Wed, Mar 2, 2016 at 10:51 AM, Cedric St-Jean > wrote: > > Hi, I have a situation that looks a bit like this: > > > > module A > > function foo end > > end > > > > module B > > import A: foo > > macro define_foo(typ, value) > > :(foo(::$(esc(typ))) = $(esc(value))) > :(A.foo(...) = ...) > > end > > end > > > > module C > > using B: @define_foo > > @define_foo Int 19 > > end > > > > A.foo(20) > > > > In other words, A is defining a function foo, B defines a macro to define > > methods of foo, and C uses the macro. This looks like it should work, > but it > > doesn't, because hygiene takes over and `foo` gets replaced with a > gensym in > > its expansion, since it's on the left-hand-side of an equality. Is there > any > > way around this? >
Re: [julia-users] Macro hygiene issue
On Wed, Mar 2, 2016 at 10:51 AM, Cedric St-Jean wrote: > Hi, I have a situation that looks a bit like this: > > module A > function foo end > end > > module B > import A: foo > macro define_foo(typ, value) > :(foo(::$(esc(typ))) = $(esc(value))) :(A.foo(...) = ...) > end > end > > module C > using B: @define_foo > @define_foo Int 19 > end > > A.foo(20) > > In other words, A is defining a function foo, B defines a macro to define > methods of foo, and C uses the macro. This looks like it should work, but it > doesn't, because hygiene takes over and `foo` gets replaced with a gensym in > its expansion, since it's on the left-hand-side of an equality. Is there any > way around this?
[julia-users] Macro hygiene issue
Hi, I have a situation that looks a bit like this: module A function foo end end module B import A: foo macro define_foo(typ, value) :(foo(::$(esc(typ))) = $(esc(value))) end end module C using B: @define_foo @define_foo Int 19 end A.foo(20) In other words, A is defining a function foo, B defines a macro to define methods of foo, and C uses the macro. This looks like it should work, but it doesn't, because hygiene takes over and `foo` gets replaced with a gensym in its expansion, since it's on the left-hand-side of an equality. Is there any way around this?