Skip to content

infix .* parses differently than standalone .* #38176

@pdeffebach

Description

@pdeffebach

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!

cc @simeonschaub

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsThis change adds or pertains to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions