Skip to content

Instantly share code, notes, and snippets.

@natefaubion
Created October 4, 2013 02:22
Show Gist options
  • Save natefaubion/6820052 to your computer and use it in GitHub Desktop.
Save natefaubion/6820052 to your computer and use it in GitHub Desktop.
wonky hygiene
macro $opt {
case { $mac () } => {
var mac = #{ $mac };
var a = makeIdent('a', mac);
var b = makeIdent('b', mac);
var code1 = withSyntax($a = [a], $b = [b]) {
return #{
{
if (b == 2) {
a + b
}
}
}
}
var code2 = withSyntax($a = [a], $b = [b], $block = code1) {
return #{
if (a == 1) $block
}
}
var code3 = withSyntax($a = [a], $b = [b]) {
return #{
var $a = 1;
var $b = 2;
}
}
return code3.concat(code2);
}
}
$opt()
@natefaubion
Copy link
Author

Result:

var a$157 = 1;
var b$158 = 2;
if (a$109 == 1) {
    if (b$110 == 2) {
        a$109 + b$110;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment