You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Simplified, we want to have a macro that accepts a do-block argument.
macrofoo(f, ex...)
@show f
return :(nothing)
end
This works just fine.
julia>@foo(a, b, c) do x, y, z
println("Hello!")
end
f = :((x, y, z)->begin#= REPL[2]:2 =#println("Hello!")
end)
However, things get more interesting when we have to qualify the name of @foo because it's in a module.
julia>module FooModule
macrofoo(f, ex...)
@show f
return :(nothing)
endend
Putting the @ on the macro name doesn't work.
julia> FooModule.@foo(a, b, c) do x, y z
println("Hello!")
end
ERROR: syntax: invalid syntax "FooModule.@foo # REPL[2], line 1 a b c do x, y # REPL[2], line 1 z # REPL[2], line 2 println("Hello!")end"
while putting the @ in front of the module name does.
julia>@FooModule.foo(a, b, c) do x, y, z
println("Hello!")
end
f = :((x, y, z)->begin#= REPL[6]:2 =#println("Hello!")
end)
The macro expansion returns strangeness (it should return Main.FooModule.nothing since that's... what the macro expands to).
julia>@macroexpand FooModule.@foo(a, b, c) do x, y z
println("Hello!")
end
:($(Expr(:., :FooModule, :($(Expr(:copyast, :($(QuoteNode(:(#= REPL[3]:1 =#@foo a b c do x, y
#= REPL[3]:1 =#
z
#= REPL[3]:2 =#println("Hello!")
end))))))))))
It's worth nothing that the macro expansion of @FooModule.foo doesn't even work.
For context, this is for JuliaGizmos/WebIO.jl#306.
Simplified, we want to have a macro that accepts a do-block argument.
This works just fine.
However, things get more interesting when we have to qualify the name of
@foo
because it's in a module.Putting the
@
on the macro name doesn't work.while putting the
@
in front of the module name does.The macro expansion returns strangeness (it should return
Main.FooModule.nothing
since that's... what the macro expands to).It's worth nothing that the macro expansion of
@FooModule.foo
doesn't even work.This is adjacent to #1769.
The text was updated successfully, but these errors were encountered: