I should start off, not entirely sure this is an okay thing to do with 
Julia. Suppose I want to create a macro that generates another macro, I can 
write:

macro meta_macro(x)
  quote
    macro foo(y)
      $x+y
    end
  end
end

and then call it and the generated macro:

@meta_macro(5)
println(@foo(3))
# 8

Okay, wasn't entirely sure that was going to work, but it appears to. 
However, if I try to move the exact same macro code into a module, it no 
longer works:

module meta_macro_mod

export @meta_macro, @foo

macro meta_macro(x)
  quote
    macro foo(y)
      $x+y
    end
  end
end

end

Even without trying to invoke `@foo`, when I execute `@meta_macro`, I get:

ERROR: syntax: invalid macro definition


It seems like how the macro gets evaluated changes when it's in the module. 
If I change it to a module to just doing an 'include', everything works 
again.

Reply via email to