-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation
Description
I really appreciate #37583, it will hopefully make metaprogramming easier.
However I don't think the full features of .* etc. work properly yet. Here is an MWE
julia> function makevec(ex)
if ex.head == :call &&
all(s -> s isa QuoteNode, ex.args[2:end])
source = Expr(:vect, ex.args[2:end]...)
fun = ex.args[1]
quote
$source => ($fun)
end
end
end;
julia> macro makevec(ex)
esc(makevec(ex))
end;
julia> @makevec :x + :y
[:x, :y] => (+)
julia> @makevec :x .+ :y
ERROR: UndefVarError: .+ not defined
Stacktrace:
[1] top-level scope
@ REPL[37]:8
julia> [:x, :y] => (.+)
[:x, :y] => Base.Broadcast.BroadcastFunction(+)
I'm not experienced enough with metaprogramming to know exactly at what stage Julia is testing for the existence of .+. However note that
julia> getproperty(Main, :.+)
ERROR: UndefVarError: .+ not defined
Any insights are appreciated!
Metadata
Metadata
Assignees
Labels
docsThis change adds or pertains to documentationThis change adds or pertains to documentation