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

Expander not using lexical context of macro definition site #97

Closed
97jaz opened this issue Sep 22, 2013 · 2 comments
Closed

Expander not using lexical context of macro definition site #97

97jaz opened this issue Sep 22, 2013 · 2 comments

Comments

@97jaz
Copy link

97jaz commented Sep 22, 2013

This:

var umem = new Uint8Array(1024);

macro word {
  rule { ($addr:expr) } => { ((umem[$addr] << 8) | umem[($addr)+1]) }
}

word(4);

expands to this:

var umem$186 = new Uint8Array(1024);
umem[4] << 8 | umem[4 + 1];

So, umem is being renamed at its definition site, but the expansion isn't using that name.

@97jaz
Copy link
Author

97jaz commented Sep 22, 2013

Oh, but I see it does work as a case macro:

macro word {
  case { _ ($addr:expr) } => { return #{((umem[$addr] << 8) | umem[($addr)+1])} }
}

Is it intentional that it doesn't word as a rule macro? Scheme's syntax-rules does handle this.

@disnet
Copy link
Member

disnet commented Sep 22, 2013

Nope, not intentional. Looks like a bug in rule macros.

@disnet disnet closed this as completed in 916a651 Sep 23, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants