Expr clearly works:
julia> macro escape_all(xs...) Expr(:tuple, esc.(xs)...) end @escape_all (macro with 1 method) julia> @macroexpand @escape_all xyz :((x, y, z))
But you can also use the following unquote syntax in a context in which it seems to me to use list matching (e.g. ,@ in Lisp):
julia> macro escape_list(xs...) :([$(esc.(xs)...)]) end @escape_list (macro with 1 method) julia> macro escape_f(xs...) :(f($(esc.(xs)...))) end @escape_f (macro with 1 method) julia> @macroexpand @escape_list xyz :([x, y, z]) julia> @macroexpand @escape_f xyz :((Main.f)(x, y, z))
Funny, I never saw $(x...) say anywhere. I stumbled upon this having recently read the code. But it is referred to in the current "recent" documents as splatting interpolation .
source share