Arrow binding

Alex Russell alex at
Mon Apr 23 10:00:51 PDT 2012

On Apr 23, 2012, at 3:30 PM, Russell Leggett wrote:

> > That is only true for functions that actually use |this|. Even though bind
> > is probably not used in force yet because of cross-browser worries, "var
> > self = this" is used everywhere. Functions using that pattern are no more
> > usable with call/apply than arrow functions.
> "everywhere" is incredibly strong wording, and I think that in the
> large, you're probably not correct. Some large % of code might
> manually "call their scope" through closure binding, but even that
> isn't an argument against soft binding.
> Let me reword from "everywhere" to "extremely common". My point was that even though it is not used in every case, it is used often enough that |this| cannot be relied on. And my other point was that you have to know how the function passed in *uses* this, which makes it pretty tightly coupled.
> > Last I checked, the new method form is still a dynamic binding - otherwise
> > it wouldn't work. So really, you're just talking about arrow functions. In
> > the cases where arrow functions make the most sense (callbacks) you rarely
> > want a dynamic |this| - the oddball case being event handlers primarily.
> Having done this dance a couple of times, let me suggest to you that
> the method form will *eventually* end up at a per-class getter on the
> prototype which vends an instance function which is bound. People will
> (reasonably) want binding of some sort.
> If that happens, then I will be more inclined to agree with you. Until that happens, I guess I just don't. Your argument seems balanced on something which you think will happen. I find that hard to agree with.
> > I really just don't see the value of changing the |this| value of a function
> > created for the purpose of being an argument to a function. And frankly, I
> > just don't see many other use cases for arrows. Maybe thats the part I'm
> > missing.
> Yeah, I think you're missing the composition arguments. If I create
> mixins with methods, they're going to have a promiscuious "this" as a
> *feature*. You might not write code like this today, but you probably
> should ;-)
> I use mixins all the time, I just don't see them being being declared with arrow functions, which was the point I was trying to make here. If you are creating a mixin, then you would most likely want to use the new method syntax or at least the function syntax, but I think it would be silly to use the arrow function syntax, so I guess I'm just not sympathetic to that.

If methods on classes sprout binding of some sort, this will be the natural style. And I think that's a good place to be. If both arrow and class methods lexically soft-bind, truly unbound functions will be declared as "function" and will be easy to spot.

More information about the es-discuss mailing list