Skip to content

Instantly share code, notes, and snippets.

@1995hnagamin
Created September 1, 2014 15:03
Show Gist options
  • Save 1995hnagamin/c96499285f2e4aa26d9b to your computer and use it in GitHub Desktop.
Save 1995hnagamin/c96499285f2e4aa26d9b to your computer and use it in GitHub Desktop.
Sweet.js上でマクロを定義する動かないマクロ
macro fun {
rule {
$name($param (,) ...) {
$body ...
}
} => {
macro $name {
rule { ($param (,) ...) } => {
$body ...
}
}
}
}
fun swap(a, b) {
var tmp = $a;
$a = $b;
$b = tmp;
}
/*
macro swap {
rule { ($a, $b) } => {
var tmp = $a;
$a = $b;
$b = tmp
}
}*/
var tmp = 10;
var b = 20;
swap(tmp, b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment