arrow function syntax simplified

Angus Croll anguscroll at
Sat Apr 7 23:30:14 PDT 2012

On Fri, Mar 30, 2012 at 4:46 AM, Felix Böhm <esdiscuss at> wrote:

> How about a "loose-bound" |this|, so that the function falls back to the
> bound |this| instead of the global scope when no other options are
> available (or `null` or `undefined` are passed to `.apply/.bind/.call`)?
I strongly support this proposal.

Any legacy utility (3rd party or otherwise) that assumes its function
arguments are dynamically bound (a reasonable assumption as of ES 5.1) will
be in trouble when passed hard-bound fat arrow functions. Here's a gist
illustrating a simplified version of a functional mixin process and how it
would break under the current fat arrow proposal.

Yes we could use the long-form function instead, but it
seems unnecessarily restrictive (not to mention confusing) that the
much anticipated short-form syntax should be out-of-bounds whenever there
is a remote possibility that the function may at some time need invoking
with a different |this| value (and how can we even anticipate such
a requirement? - especially if we are writing 3rd party libraries)

And yes there is an ES 5 precedent - Function::bind also makes a hard
binding, but with bind there are no surprises, it is intentional and
explicit - fat arrow lexical binding OTOH will probably be an unexpected
side effect for those developers whose primary goal is to save key strokes.

Under Felix's proposal I'm assuming a soft-lexical binding would be
overridable by call and apply (provided a valid context object is passed)
or by the base reference of a method invocation. In other words if a |this|
value is provided, use it, otherwise default to the lexical scope instead
of the global scope.

I'm betting that covers most of the current |this| headaches we are trying
to solve while keeping short-form syntax in play for those of us who
value/rely on dynamic binding.


> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list