Using @sprintf inside a macro

Splatting doesn’t quite work like this in macro calls. Try:

macro myprintf(x, y...)
    :(print(now(), ":", @sprintf($x, $(esc.(y)...))))
end

instead. You need to do the splatting inside the interpolation, for y to be spliced correctly into the expression.

Edit: I don’t think you even need the esc.

2 Likes