Arrow functions as methods
brendan at mozilla.org
Wed Jul 11 23:02:35 PDT 2012
Gordon Brander wrote:
> I noticed an alternative solution to this problem in the ES Wiki:http://wiki.ecmascript.org/doku.php?id=harmony:arrow_function_syntax#deferred (see "optional leading `this` initializer"). As I understand it, that would give us some sort of special delimiter for specifying a soft-bound `this` context on a thin-arrow, e.g. in pseudo-code:
> foo(o | a, b)
> ...or some-such.
That syntax was for expressions and definitions of functions, not for
calls. The idea was to enable parameter default values for |this|. It
won't do what Irakli wants.
Soft-bind is not going to fly, see
Implicitly shifting |this| in call expressions to the front of the
actual argument list is similarly painful in overhead for implementors,
besides making the dynamic "two args, or only one?" hazard depending on
how a callee called from a polymorphic site happened to be expressed.
What Python does is a bit different:
for some identifier-expression 'foo'. But this depends on classes in
Python, which are not in any way analogous to => function expressions.
More information about the es-discuss