I tried to make an argument list for a closure from a tuple of symbols. MWE:
## what I want
macro_helper1(arguments, form) = :($(Expr(:tuple, arguments...)) -> $form)
## how I tried to do it first
macro_helper2(arguments, form) = :($arguments -> $form)
difference:
julia> macro_helper1((gensym(:a),gensym(:b)), :(f(something))) # good solution
:((##a#321,##b#322)->begin # REPL[168], line 1:
f(something)
end)
julia> macro_helper2((gensym(:a),gensym(:b)), :(f(something))) # wrong solution
:((Symbol("##a#323"),Symbol("##b#324"))->begin # REPL[170], line 1:
f(something)
end)
I figured out the Expr(:tuple,...)
using dump
.
- Is this the expected behavior?
- Could someone please explain why? (I would learn a lot from it).
- How to do this without
Expr
?