Created
September 1, 2014 15:03
-
-
Save 1995hnagamin/c96499285f2e4aa26d9b to your computer and use it in GitHub Desktop.
Sweet.js上でマクロを定義する動かないマクロ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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