Bound instance-function vending (was RE: Arrow binding)

Kevin Smith khs4473 at gmail.com
Sat Apr 28 11:49:44 PDT 2012


Hi Angus!

1) Kevin et al suggested YAGN call/apply on (non-method) functions. Here's
> a pretty neat example where call/apply is a perfect fit for standalone
> functions - and would break if replaced with fat arrows.
>
> https://gist.github.com/2520731
>

This is a great example.  Two points:

1.)  In this case, I think it's going to be pretty difficult to prove that
a "dynamic this" arrow function would be any more readable or "better" than
current syntax:

    // On what basis is this:
    this.initialize = () -> { ... };

    // any better than this?
    this.initialize = function() { ... };

There are a couple of characters saved, but it's less readable.  Why
introduce new syntax for such dubious gain?

2.) For mixin stuff like your example, I think the elegant solution is
"object literal extension" syntax:

    https://gist.github.com/2521128

I'm not sure of the status of that syntax, but hopefully it will get
included in ES6.

kevin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120428/db6c2eff/attachment.html>


More information about the es-discuss mailing list