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

weird behavior with macro inside a module #1521

Closed
mlubin opened this issue Nov 9, 2012 · 5 comments
Closed

weird behavior with macro inside a module #1521

mlubin opened this issue Nov 9, 2012 · 5 comments

Comments

@mlubin
Copy link
Member

mlubin commented Nov 9, 2012

module Foo
export @bob1

macro bob1(expr)
    :(1+$expr)
end
end

macro bob2(expr)
    :(1+$expr)
end

using Foo
println(@bob2(1)) # works
println(@bob1(1)) # doesn't work

prints:

2
in @bob1: expr not defined
...

I might be doing something wrong, but not sure why this doesn't work.

@mlubin
Copy link
Member Author

mlubin commented Nov 9, 2012

Obrigado a @tautologico, this is fixed if you add using Base. The complaint is about Base.expr.

@mlubin mlubin closed this as completed Nov 9, 2012
@pao
Copy link
Member

pao commented Nov 9, 2012

Why isn't using Base implicit by default, again?

@mlubin
Copy link
Member Author

mlubin commented Nov 9, 2012

Good question

@pao
Copy link
Member

pao commented Nov 9, 2012

Opened #1522 to discuss that follow-up.

@toivoh
Copy link
Contributor

toivoh commented Nov 9, 2012

@JeffBezanson: Is there a reason to have AST interpolation refer to expr in the current scope and not Base.expr?
Unlike e.g. ref, I have a hard time seeing when someone would want to overload expr to change that behavior.
(I guess the same goes for tuple and e.g. (1,2))

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

3 participants