Unbound arrow functions?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Unbound arrow functions?

Isiah Meadows

There already exists a syntax for lexically bound functions, but couldn't there be an unbound counterpart? I am aware I brought this up before, but I'm still missing it with smaller methods that still need `this`. It's easy to macro, but it feels weird to have a lexically bound lambda and not an unbound equivalent to the anonymous function expression.

<aside class="biased">
Also, it's the only reason CoffeeScript still seems attractive in any way. I know I'm a little opinionated in this area, but I'd rather use ES 2015 to CoffeeScript any day.
</aside>


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Erik Arvidsson
ES'15 provides dedicated method syntax. What are your use cases that are not covered by methods?

On Sat, Jun 20, 2015 at 12:13 PM Isiah Meadows <[hidden email]> wrote:

There already exists a syntax for lexically bound functions, but couldn't there be an unbound counterpart? I am aware I brought this up before, but I'm still missing it with smaller methods that still need `this`. It's easy to macro, but it feels weird to have a lexically bound lambda and not an unbound equivalent to the anonymous function expression.

<aside class="biased">
Also, it's the only reason CoffeeScript still seems attractive in any way. I know I'm a little opinionated in this area, but I'd rather use ES 2015 to CoffeeScript any day.
</aside>

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

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Herby Vojčík


Dňa 20. júna 2015 19:31:18 CEST používateľ Erik Arvidsson <[hidden email]> napísal:
> ES'15 provides dedicated method syntax. What are your use cases that
> are
> not covered by methods?

Or, ultimately, by function keyword. If I understand correctly, what you want is "arrowlike" equivalent of what function keyword already provides. If it is not the case, just ignore the rest. If it is, the state is, IIRC, that this went through the discussion some year ago and the consensus was, no shorter form of function should be added just for convenience - only the lexically bound one as it actually brings actual added value.

> On Sat, Jun 20, 2015 at 12:13 PM Isiah Meadows <[hidden email]>
> wrote:
>
> > There already exists a syntax for lexically bound functions, but
> couldn't
> > there be an unbound counterpart? I am aware I brought this up
> before, but
> > I'm still missing it with smaller methods that still need `this`.
> It's easy
> > to macro, but it feels weird to have a lexically bound lambda and
> not an
> > unbound equivalent to the anonymous function expression.
> >
> > <aside class="biased">
> > Also, it's the only reason CoffeeScript still seems attractive in
> any way.
> > I know I'm a little opinionated in this area, but I'd rather use ES
> 2015 to
> > CoffeeScript any day.
> > </aside>
> > _______________________________________________
> > es-discuss mailing list
> > [hidden email]
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Isiah Meadows

Good point. I just wish there was some shorter form for methods, but I guess that's probably a little more for Sweet.js macros than this.


On Sat, Jun 20, 2015, 14:48 Herby Vojčík <[hidden email]> wrote:


Dňa 20. júna 2015 19:31:18 CEST používateľ Erik Arvidsson <[hidden email]> napísal:
> ES'15 provides dedicated method syntax. What are your use cases that
> are
> not covered by methods?

Or, ultimately, by function keyword. If I understand correctly, what you want is "arrowlike" equivalent of what function keyword already provides. If it is not the case, just ignore the rest. If it is, the state is, IIRC, that this went through the discussion some year ago and the consensus was, no shorter form of function should be added just for convenience - only the lexically bound one as it actually brings actual added value.

> On Sat, Jun 20, 2015 at 12:13 PM Isiah Meadows <[hidden email]>
> wrote:
>
> > There already exists a syntax for lexically bound functions, but
> couldn't
> > there be an unbound counterpart? I am aware I brought this up
> before, but
> > I'm still missing it with smaller methods that still need `this`.
> It's easy
> > to macro, but it feels weird to have a lexically bound lambda and
> not an
> > unbound equivalent to the anonymous function expression.
> >
> > <aside class="biased">
> > Also, it's the only reason CoffeeScript still seems attractive in
> any way.
> > I know I'm a little opinionated in this area, but I'd rather use ES
> 2015 to
> > CoffeeScript any day.
> > </aside>
> > _______________________________________________
> > es-discuss mailing list
> > [hidden email]
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Erik Arvidsson

At one point in time we allowed concise bodies in classes and object literals but the commas in object literals made the syntax problematic.


On Sun, Jun 21, 2015, 00:58 Isiah Meadows <[hidden email]> wrote:

Good point. I just wish there was some shorter form for methods, but I guess that's probably a little more for Sweet.js macros than this.


On Sat, Jun 20, 2015, 14:48 Herby Vojčík <[hidden email]> wrote:


Dňa 20. júna 2015 19:31:18 CEST používateľ Erik Arvidsson <[hidden email]> napísal:
> ES'15 provides dedicated method syntax. What are your use cases that
> are
> not covered by methods?

Or, ultimately, by function keyword. If I understand correctly, what you want is "arrowlike" equivalent of what function keyword already provides. If it is not the case, just ignore the rest. If it is, the state is, IIRC, that this went through the discussion some year ago and the consensus was, no shorter form of function should be added just for convenience - only the lexically bound one as it actually brings actual added value.

> On Sat, Jun 20, 2015 at 12:13 PM Isiah Meadows <[hidden email]>
> wrote:
>
> > There already exists a syntax for lexically bound functions, but
> couldn't
> > there be an unbound counterpart? I am aware I brought this up
> before, but
> > I'm still missing it with smaller methods that still need `this`.
> It's easy
> > to macro, but it feels weird to have a lexically bound lambda and
> not an
> > unbound equivalent to the anonymous function expression.
> >
> > <aside class="biased">
> > Also, it's the only reason CoffeeScript still seems attractive in
> any way.
> > I know I'm a little opinionated in this area, but I'd rather use ES
> 2015 to
> > CoffeeScript any day.
> > </aside>
> > _______________________________________________
> > es-discuss mailing list
> > [hidden email]
> > https://mail.mozilla.org/listinfo/es-discuss
> >
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> es-discuss mailing list
> [hidden email]
> https://mail.mozilla.org/listinfo/es-discuss


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Allen Wirfs-Brock

On Jun 21, 2015, at 7:42 AM, Erik Arvidsson wrote:

At one point in time we allowed concise bodies in classes and object literals but the commas in object literals made the syntax problematic.

We also talked about the possibility of allow ;  as an alternate separator in object literals.  But it didn't find much traction.

Allen

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Unbound arrow functions?

Andy Earnshaw-2
The thing I liked about thin arrows (other than the conciseness) was the lack of a prototype object, thus automatically throwing on construct and having similar behaviour to native functions.  Concise methods and fat arrows already have this behaviour, but if you want to add such a method to an already existing object you have to resort to using Object.assign (or have a function with a prototype that is made to throw on construct).

Of course, if we made .prototype configurable for non-builtins we could always delete to get the same behaviour.  Not sure how viable that is, or if it's worth it for such a minor convenience.

On Mon, 22 Jun 2015 at 01:07 Allen Wirfs-Brock <[hidden email]> wrote:

On Jun 21, 2015, at 7:42 AM, Erik Arvidsson wrote:

At one point in time we allowed concise bodies in classes and object literals but the commas in object literals made the syntax problematic.

We also talked about the possibility of allow ;  as an alternate separator in object literals.  But it didn't find much traction.

Allen
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

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