Example of real world usage of function bind syntax

Domenic Denicola d at domenic.me
Thu Jun 11 18:19:10 UTC 2015

I don’t think we should make it easier to shoot yourself in the foot by auto-binding methods (and thus creating new copies of the method for every instance of the class).

From: Matthew Robb [mailto:matthewwrobb at gmail.com]
Sent: Thursday, June 11, 2015 14:16
To: Jordan Harband
Cc: Domenic Denicola; Kevin Smith; es-discuss
Subject: Re: Example of real world usage of function bind syntax

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<mailto: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<mailto: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<mailto:es-discuss at mozilla.org>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150611/0402ac80/attachment-0001.html>

More information about the es-discuss mailing list