I'm trying to write a macro that takes up a function definition and outputs another one. It starts like:
macro mac(fdef) @capture(fdef, begin function fname_ (args__) body__ end end) :(function $(esc(fname)) ($(args...)) ... end) end Macrotools are very convenient for getting the args, but I have issues putting them back into place. I thought it wouldn't matter if they were gensym'ed, but it turns out that arguments like (x::SomeType) will have SomeType resolved in the macro's environment, which is obviously wrong. So I need to escape hygiene. Something like $(esc(args)...), but that does not work, as esc returns an Expr. I thought that $(map(esc, args)...) could make sense, but it's complaining that: :($(Expr(:error, "\"(escape x)\" is not a valid function argument name"))) Enter code here... which makes little sense to me. Any ideas? Cédric