First, open up Textmate and go to
Bundle Editor then
variable.language.js. Here you'll see that
this are lumped together. All we need to do is add our friend (and an additional pipe symbol) to the list:
That's all that's required to make
_this a first-class, syntax-highlighted, citizen. Now your callbacks are nice and legible.
And there we go! You can also add in
self if you're not a
And in case you weren't convinced by my compelling arguments - Dave Sims leaves you with this piece of food-for-thought from The Deer Hunter...
Have you considered using some precompiler thingy to skip writing “var _this = this”? I know JSShaper should be able to do this.
I know it adds some extra cruft to dev work. In case you use a build system already this shouldn’t really matter that much, though.
My build system is Textmate->Browser, but I’m looking to cut out the “Textmate” part.
Though, not that I ever get beyond v0.1 anyway…
But JSShaper is interesting… your operator overloading idea is very cool!
Woo nice idea!
BTW, I prefer using “self” intead of “_this” , like in python :) but everyone got his conventions ;)
This is this. It isn’t something else.