As far as I can tell, below macro is the identity-macro and works for
everything I tried but for module definitions.  Why?  In fact, I
struggle to get a module definition working within a macro.

    julia> macro id(ex)
               :($(esc(ex)))
           end
    
    julia> @id x=5
    5
    julia> @id type MT end
    
    julia> @id module MO end
    ERROR: invalid method definition: not a generic function

Second example:

    macro typ(ex) # this works and produces type TY
        :(esc(type TY end))
    end
    
    macro mod(ex) # this doesn't
        :(esc(module MO end))
    end
    
    ERROR: syntax: malformed module expression

Is there a way to define modules within macros?

Reply via email to