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

macros should be scoped like functions #339

Closed
StefanKarpinski opened this issue Jan 13, 2012 · 6 comments
Closed

macros should be scoped like functions #339

StefanKarpinski opened this issue Jan 13, 2012 · 6 comments
Assignees
Labels
breaking This change will break code

Comments

@StefanKarpinski
Copy link
Member

julia> let x = 1
         macro foo(v)
           :($v+1)
         end
         @foo x
       end
syntax error: macro foo not defined
in run_repl, /Users/stefan/projects/julia/j/client.j:22
in _start, /Users/stefan/projects/julia/j/client.j:134

Ideally, the macro @foo would exist only within the scope of the let block.

@ghost ghost assigned JeffBezanson Jan 13, 2012
@JeffBezanson
Copy link
Member

Yes, I know... Scheme got this perfect but I really don't think we'll have time to work on these little staging and scoping details that most people don't notice. Maybe in version 4 :)

@StefanKarpinski
Copy link
Member Author

Yeah, that's fair. I'm just opening an issue so that we know to do it when we have time someday.

@johnwcowan
Copy link

IMAO, local macros are more trouble than they are worth. Macros extend the syntax of the language, which is a Good Thing. Local macros are about making the syntax different in some places than other places, which strikes me as a Bad Thing.

@pao
Copy link
Member

pao commented Nov 3, 2012

Macros do currently have some locality in that they can be limited to a module scope.

@StefanKarpinski
Copy link
Member Author

Honestly that seems like as much locality as one really needs. The reason I wanted this originally was to be able to define and use macros without having them pollute the global namespace. Having them be module-local addresses that.

@StefanKarpinski
Copy link
Member Author

To that end, macro declarations should probably be allowed in the same places that module declarations are.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code
Projects
None yet
Development

No branches or pull requests

4 participants