Gist to add CoffeeScript friendly argument order to Underscore.js(gist.github.com)
gist.github.com
Gist to add CoffeeScript friendly argument order to Underscore.js
https://gist.github.com/2624704
5 comments
Very cool - I like that alot.
There's probably a way to programmatically add that for every underscore function, but there's probably not a _good_ way...
There's probably a way to programmatically add that for every underscore function, but there's probably not a _good_ way...
In the past few months I’ve moved to named functions for any timers/event bindings/callbacks longer than a single statement. Keeps things more manageable in general, and as a bonus, sidesteps this issue.
Spaghetti’s tasty, but belongs on your plate, not your computer.
Spaghetti’s tasty, but belongs on your plate, not your computer.
You can also call the original method without the ugly leading comma like this:
_.throttle(
->
console.log("Foo")
500
)Is there any reason coffeescript can't be extended to support the same thing without parentheses? That feels fairly natural to me since it's similar to the object literal syntax.
Edit: Couldn't find that this has ever been suggested before, so I created a github issue: https://github.com/jashkenas/coffee-script/issues/2307
Edit: Couldn't find that this has ever been suggested before, so I created a github issue: https://github.com/jashkenas/coffee-script/issues/2307
[deleted]
For others who were confused like me: the title refers to argument order that is easy to write in CoffeeScript, not the (non-existent) "friendly argument order" feature of CoffeeScript.
Oops that was meant to be (CoffeeScript friendly) argument order, not CoffeeScript (friendly argument order). English needs better operator precedence.
Thanks
Thanks
A hyphen would be useful here: “CoffeeScript-friendly argument order”.
I agree, lets make a pull request to... after a little research looks like there is no language regulator for English (http://en.wikipedia.org/wiki/List_of_language_regulators) :/
Nice thing about that is you don't have to rememeber arg order (though you do have to remember the kv names). In coffee though you have less commas, feels nearly smalltalkish.