On Wed, Mar 28, 2012 at 1:37 PM, David Herman <[email protected]> wrote:

> On Mar 27, 2012, at 9:14 PM, Russell Leggett wrote:
>
> > I'm sure this is a bit of a tangent, but the other major related case is
> passing a "method" as an argument but needing to retain the correct "this".
> Obviously, that is what bind was meant for, but that is inconvenient when
> passing methods for the same reason it would be inconvenient for anonymous
> functions.
> >
> > What if we had a shorthand for bind that worked in both of these cases...
>
> I have a strawman on this topic:
>
>    http://wiki.ecmascript.org/doku.php?id=strawman:bind_operator
>
> I agree it's a real need. Just like ... will provide convenient,
> high-fidelity (e.g., insensitive to Function.prototype monkey-patching)
> syntax for .apply, we should also have an operator that provides
> convenient, high-fidelity syntax for .call and .bind. I believe a single
> operator can provide both.
>

Ah, there you go. I figured I wasn't the first to think of it. I think it
might be worth talking about this in relation to the shorthand function
syntax, because it could pull the lexical this issue out of that debate.
Then we could reduce the arrows to something simpler: -> for blocks, => for
expressions with implicit return. It would also solve the related issue of
this binding when passing methods as callbacks, which is also a major issue
in a lot of apis, requiring extra parameters for the "this".

- Russ


>
> Dave
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to