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

There's no question that the generated JavaScript is never going to be as pretty as handwritten JS. But that said, choosing splats as your example of bad syntax isn't the best choice, because there isn't a syntactic equivalent in JavaScript.

This CoffeeScript:

    send_letter: (name, addresses...) ->
      # more code...
Where the array of addresses can be referenced and used as many times as you like within the function body, would need to be translated as this JavaScript:

    var send_letter = function send_letter(name) {
      var addresses = Array.prototype.slice.call(arguments, 1);
      # more code...
    };
Which is both a good bit more to type, as well as more work -- you need to figure out the index from which to slice. The only difference with the generated JS is that the variable declaration is on a separate line -- a feature that allows all assignments to be used as part of a larger expression.


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

Search: