jlongster / es6-macros

A collection of sweet.js macros that implement ES6 features for ES5
BSD 2-Clause "Simplified" License
238 stars 18 forks source link

Some ideas #25

Open kristianmandrup opened 9 years ago

kristianmandrup commented 9 years ago

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.

vendethiel commented 9 years ago

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

kristianmandrup commented 9 years ago

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???