Skip to content

Instantly share code, notes, and snippets.

@btd
Last active January 4, 2016 18:59
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save btd/8663940 to your computer and use it in GitHub Desktop.
Save btd/8663940 to your computer and use it in GitHub Desktop.
One attempt to make arrow functions from es6
macro => {
rule infix { ( $arg:ident (,) ... ) | { $body ... $last:expr } } => {
(function x( $arg (,) ... ) {
$( $body) ...
return $last
}).bind(this);
}
rule infix { ( $arg:ident (,) ... ) | $last:expr } => {
(function x( $arg (,) ... ) {
return $last
}).bind(this);
}
rule infix { () | { $body ... $last:expr } } => {
(function x( ) {
$body ...;
return $last
}).bind(this);
}
rule infix { $x | { $body ... $last:expr } } => {
(function x($x) {
$body ...;
return $last
}).bind(this);
}
rule infix { $x | $last:expr } => {
(function x($x) {
return $last
}).bind(this);
}
}
@torgeir
Copy link

torgeir commented Jun 5, 2014

The semicolons error on something like [1, 2, 3].map(x => x+1);

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