My only major complaint with Coffeescript is that it doesn't have a construct for handling the context-sensitive 'this' keyword. I still have to write
self= @
at the top of functions. The fat arrow for binding 'this' certainly helps but when you have to be really careful when writing code that nests several functions.
Also, would be nice if the for-loop had a way to automatically wrap the block in a function without having to write
The fat arrow is a great helper and saves a lot of work in various situations....obviously it doesn't cover all situations...but in the situations it doen't cover I'm not sure what I'd expect the language to do.
Could you give an example of what you imagine the feature to be?
I'm just not sure if something as simple and easy as
that = @
needs improvement. Anything beyond what that and => covers, to me seems like something a library should handle...and CS makes that very easy.
For you second one, what about
do ( -> whatever x ) for x in foobar
One of the things I like about CS is that it is very conservative about not adding helpers for every little thing you can think of. It chooses a few very powerful and fundamental building blocks, and let's you use those to build up yourself.
I find all of these pretty readable and easy. The former in simple cases like "whatever x", and the latter two when you are doing more than just "whatever x".
I think it's important to distinguish cases like this and that the syntax is clean enough without adding some helper that makes what's going on implicit
I often have to resort to self = @ when using jQuery in classes.
Because of how jQuery binds the queried element to this, and the fat arrow overrides this, there doesn't seem to be another way to access both your class and the jQuery element in the same function.
Try `event.currentTarget`, and `event.target` instead. They're much preferable to having a `self` (representing some random DOM element), and a `this` within a function.
Also, would be nice if the for-loop had a way to automatically wrap the block in a function without having to write