Skip to content

Instantly share code, notes, and snippets.

@vendethiel
Forked from int3/gist:4013740
Last active January 2, 2016 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vendethiel/8230362 to your computer and use it in GitHub Desktop.
Save vendethiel/8230362 to your computer and use it in GitHub Desktop.
coffee's do, fix for new sweet.js
macro $do {
rule {($($x = $y) (,) ...) $body} => {
(function ($x (,) ...) $body)($y (,) ...)
}
rule {$name ($($x = $y) (,) ...) $body} => {
(function $name ($x (,) ...) $body)($y (,) ...)
}
}
$do (a = 1, b = 2) {
return a + b;
}
/* result:
(function (a$15, b$16) {
return a$15 + b$16;
}(1, 2));
*/
console.log($do fib(n=7) {
if (n > 1) return fib(n - 1) + fib(n - 2);
return 1;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment