JuliaVariables.jl icon indicating copy to clipboard operation
JuliaVariables.jl copied to clipboard

Macro arguments are treated as globals

Open tkf opened this issue 6 years ago • 3 comments

It seems that macro arguments are treated as globals (see @global x)

julia> solve(:(macro f(x) end))
:(macro (@global f)(@global x)
      #= REPL[12]:1 =#
  end)

Compare this to a function:

julia> solve(:(function f(x) end))
[]function (@global f)(@x)
    #= REPL[13]:1 =#
end

Also, macro (@global f) is a bit hard to use. Would @global var"@f" make sense?

tkf avatar Nov 01 '19 07:11 tkf

macro is not handled as well.

Do you have a better idea of implementing the functionalities this repo tries to achieve? Just need help indeed.

thautwarm avatar Nov 01 '19 09:11 thautwarm

I get that macro calls Expr(:macrocall, ...) are not supported (as mentioned in README) and it perhaps is impossible to do it without implementing Julia interpreter. But isn't it a bit easier to process macro definitions Expr(:macro, ...)? I think you can process macro f(...) ... end as if it were function var"@f"(...) ... end? I think I can do this by pre-processing Expr before passing it to solve. But it would be great if JuliaVariables.jl does this out-of-the-box.

tkf avatar Nov 01 '19 20:11 tkf

Yes, I think processing macro definition is not difficult. I'm going to implememt this, thank you!!

thautwarm avatar Nov 02 '19 00:11 thautwarm