This seems to be a parser weakness:
julia> foosig = :( foo(x) )
:(foo(x))
julia> :( function $foosig 2*x end )
ERROR: syntax: expected "end" in definition of function "($ foosig)"
The error message is miselading: the parser actually wants to see parentheses after $foosig
. Note that these related constructions do parse as expected:
julia> :( $foosig = 2*x )
:(foo(x) = 2x)
julia> fooname = :foo
:foo
julia> :( function $fooname(x) 2*x end )
:(function foo(x)
#= none:1 =#
2x
end)