Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro arguments are treated as globals #10

Open
tkf opened this issue Nov 1, 2019 · 3 comments
Open

Macro arguments are treated as globals #10

tkf opened this issue Nov 1, 2019 · 3 comments

Comments

@tkf
Copy link
Contributor

tkf commented Nov 1, 2019

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?

@thautwarm
Copy link
Member

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.

@tkf
Copy link
Contributor Author

tkf commented Nov 1, 2019

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.

@thautwarm
Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants