Actually, no, I take that back. The problem here is that writing a macro to wrap a macro which recognizes $
syntax is quite subtle. This is because normal syntax interpolation will see and remove the $
before the inner quoted macro (the @cfunction
in this case) gets to do so. I think the correct macro would be something like:
macro cplprogress(progressfunc)
quote
@cfunction($(Expr(:$, esc(progressfunc))), Cint, (Cdouble, Cstring, Ptr{Cvoid}))
end
end
Then we’d have:
julia> @macroexpand @cplprogress x->x
quote
#= REPL[41]:3 =#
$(Expr(:cfunction, Base.CFunction, :(x->begin
#= REPL[43]:1 =#
x
end), :(Main.Cint), :(Core.svec(Main.Cdouble, Main.Cstring, Main.Ptr{Main.Cvoid})), :(:ccall)))
end
In any case, yes, the original macro is using @cfunction
outside a quote block, but with a $
. So this is using the closure syntax.