Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

What about the "shorter function syntax" (from strawman http://wiki.ecmascript.org/doku.php?id=strawman:shorter_func... )? I'm crossing my fingers and toes that this makes it in.


This seem to be a "bike shed" issue where everyone have their favorite syntax. Mascara supports function(a,b)a+b. "function" is still long though, so other suggestions is "#", "^", "fn", the florin-sign, "lambda" and others.

I think #(a,b)a+b is somewhat ugly, but it might win because it is unambiguous and doesn't collide with existing identifier.

My favorite lambda syntax is C#'s (a,b)=>a+b, but this may be rejected because it requires lookahead to parse.


Brendan mentioned that he was wanting to keep # for something else and just adopt the coffeescript -> as the short form.

    (x) -> x
    (x) -> (x * x)
    (x) -> {
       for(let i = 0; i < x; i++){
           console.log(i);
       }
    }
Was the set of syntax examples given.


Traceur dev here. It's on the to-do list. We've been mostly focused on stuff that's either approved for Harmony (modules, spread, etc.) or that we think will need a lot of iteration (classes, traits). I'm personally really keen on a better function syntax (especially a single-expression-body one).


We definitely could use something like this.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: