I was generally under the impression that a macro always had the return a 
`Expr`
and that doing otherwise would make the compiler yell at me.

Apparently I was wrong, at least about the second part:
https://github.com/ChrisRackauckas/ParallelDataTransfer.jl/issues/3



macro ex_timestwo(x)
    :($(esc(x))*2)
end



@ex_timestwo(4)
8

macroexpand(:(@ex_timestwo(4)))
:(4 * 2)

@ex_timestwo(a)
LoadError: UndefVarError: a not defined


macroexpand(:(@ex_timestwo(a)))
:(a * 2)



?

VS: not returning an expression, and just doing a thing:

macro n_timestwo(x)
 x*2
end


@n_timestwo(4)
8


macroexpand(:(@n_timestwo(4)))
8


@n_timestwo(a)
LoadError: MethodError: no method matching *(::Symbol, ::Int64)


macroexpand(:(@n_timestwo(a)))
:($(Expr(:error, MethodError(*,(:a,2)))))




Is this a feature?
Or is it just undefined behavior?

Reply via email to