Skip to content

Julia v0.7 @__MODULE__ problem #63

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

Closed
Qiyamah opened this issue Jun 26, 2018 · 2 comments
Closed

Julia v0.7 @__MODULE__ problem #63

Qiyamah opened this issue Jun 26, 2018 · 2 comments

Comments

@Qiyamah
Copy link

Qiyamah commented Jun 26, 2018

Julia no longer supports @current_module, so in this regard every `@macromethod should has a built in current_module variable, right? is there a plan to implement it?

@macromethod  object(head, begin *{body} end) begin
      parse_head(head)
      parse_body(body)
end

body may include macros such as

@object SS begin
    @stub fun
end

while you are parsing the body , you may want to expand the macro with macroexpand which now takes the expression and the module.

Thanks

@fcard
Copy link
Owner

fcard commented Jul 9, 2018

Yes, that's the purpose of #41. I had some trouble compiling julia but that's solved now, so I can finally come back to this. Hopefully I will have 0.7 support very soon.

@fcard
Copy link
Owner

fcard commented Jul 9, 2018

As for macro-expanding, I think that's best left to the user, because they might want to dispatch on or manipulate macro calls. The __module__ variable can be used:

@macromethod object(head, begin *{body} end) begin
    parse_head(macroexpand(__module__, head))
    parse_body((x->macroexpand(__module__, x)).(body))
end

Which now that I've typed it out looks pretty ugly, so I might implement some sort of shortcut, like:

local macroexpand(m,x) = Base.macroexpand(m, x)
macroexpand(x) = macroexpand(__module__, x)

At the start of every method or something. (I can probably think of something better)

@Qiyamah Qiyamah closed this as completed Jul 19, 2018
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