Example of real world usage of function bind syntax

Matthew Robb matthewwrobb at gmail.com
Thu Jun 11 18:16:23 UTC 2015


Here's a cool trick I found using this bind syntax today: Babel REPL
<http://babeljs.io/repl/#?experimental=true&evaluate=true&loose=false&spec=false&playground=false&code=class%20Foo%20%7B%0A%20%20bar%20%3D%20%3A%3Athis.bar%3B%0A%20%20bar()%7B%20%20%7D%0A%7D>

But it lead me to think that class methods could have `::` prefixed onto
them to suggest that they be lightly bound method references:

class X {
  ::Y() {  }
}


- Matthew Robb

On Thu, Jun 11, 2015 at 11:56 AM, Jordan Harband <ljharb at gmail.com> wrote:

> I find the call form of the operator (`a::b()`) very useful on its own.
>
> However, I think the main question is, will shipping the prefixed bind or
> prefixed call forms of the operator (`::a.b`, `::a.b()`), and/or the bind
> form of the operator (`a::b`), definitely preclude future extension
> with partial application, etc, or can those still be worked in somehow? If
> there's a way to include all four forms and leave open the future
> possibility of extension, I think, as Domenic points out, that we would see
> a lot of value from the bind and prefix forms as well.
>
>
> On Thursday, June 11, 2015, Domenic Denicola <d at domenic.me> wrote:
>
>> From: es-discuss [mailto:es-discuss-bounces at mozilla.org] On Behalf Of
>> Matthew Robb
>>
>> > ​​I would be significantly less excited about it if this happens. The
>> ability to pass around "lightly" bound references to methods is a big deal
>> imo and a large part of the value in this proposal.
>>
>> Definitely agree. Being able to do `foo.map(::this.bar)` is really great,
>> and even `const extracted = ::foo.bar` is nothing to sneeze at.
>>
>> I know there's a thread on the issue tracker where a few vocal voices are
>> complaining that they want partial application syntax and bikeshedding on
>> various operator forms related to that, but I don't think that should
>> discourage the excellent benefits that you're giving to everyone but those
>> few.
>> _______________________________________________
>> es-discuss mailing list
>> es-discuss at mozilla.org
>> https://mail.mozilla.org/listinfo/es-discuss
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150611/99733e72/attachment.html>


More information about the es-discuss mailing list