jlongster/es6-macros

Some ideas

kristianmandrup opened this issue · 2 comments

Many of the features are implemented in the LiveScript compiler already. You can type livescript syntax directly in http://livescript.net/ and see what it compiles to.

Example:

(a, b, ...c) ->
  log a

Compiles to

// Generated by LiveScript 1.3.1
var slice$ = [].slice;
(function(a, b){
  var c;
  c = slice$.call(arguments, 2);
  return log(a);
});

Would love to help in developing more es6 features! I agree, way better to enable ES5 extras via macros than via separate compilers such as traceur.

Uhm, this is just a plain ES6 feature, not related to LS.

The above example simply tells us that to get function rest arguments, we simply have to use [].slice on the last arguments with the number of arguments before the rest one. How would we do this with macros? a case macro which examines arguments.length of the function or???