Discussion:
arrow functions and dart
Francisco Ferreira
2014-09-22 21:18:48 UTC
Permalink
Hi,

Just to set some expectations, Although I follow es-discuss, I read more
than I discuss. So the point I want to achieve with this e-mail is:

I have played with dart since it was in alpha. And I also have been coding
with --harmony for a while. I would like to comment that arrow functions in
dart are much better than in ES6 (mozilla implementation).

Let's compare

In JS:
anObject.thatGetsACallback( (arg1, arg2) => { .... } );

In dart:
anObject.thatGetsACallback( (arg1, arg2) { .... } );

It seems much less invasive and it contains less characters. So my question
to es-discuss is: what is the current discussion regarding removing the
arrow for anonymous inline functions. Can we still dial back, and look at
the dart approach for inline functions?

Btw, overall discussions are awesome!
Cheers
Francisco Ferreira
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140922/0178d4fe/attachment.html>
Rick Waldron
2014-09-22 22:19:38 UTC
Permalink
On Mon, Sep 22, 2014 at 5:18 PM, Francisco Ferreira <
Post by Francisco Ferreira
Hi,
Just to set some expectations, Although I follow es-discuss, I read more
I have played with dart since it was in alpha. And I also have been coding
with --harmony for a while. I would like to comment that arrow functions in
dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
Sure, but that syntax cannot be used outside of call expression arguments.
I had a proposal in 2011 (https://gist.github.com/rwaldron/961495) that
fell down on this hazard:

var x = 1;
f = (x)
{ x }


...Which is a valid JavaScript program today, which means that `(params){
body }` cannot parse unambiguously.

Rick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140922/892e9fd8/attachment.html>
Matthew Robb
2014-09-22 22:38:07 UTC
Permalink
I think it's also worth noting that CoffeeScript uses an arrow as well and
it doesn't seem to impact usability much if at all.


- Matthew Robb

On Mon, Sep 22, 2014 at 6:19 PM, Rick Waldron <waldron.rick at gmail.com>
Post by Rick Waldron
On Mon, Sep 22, 2014 at 5:18 PM, Francisco Ferreira <
Post by Francisco Ferreira
Hi,
Just to set some expectations, Although I follow es-discuss, I read more
I have played with dart since it was in alpha. And I also have been
coding with --harmony for a while. I would like to comment that arrow
functions in dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
Sure, but that syntax cannot be used outside of call expression arguments.
I had a proposal in 2011 (https://gist.github.com/rwaldron/961495) that
var x = 1;
f = (x)
{ x }
...Which is a valid JavaScript program today, which means that `(params){
body }` cannot parse unambiguously.
Rick
_______________________________________________
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/20140922/e5c77ae6/attachment.html>
Salvador de la Puente González
2014-09-23 08:30:36 UTC
Permalink
Proposal:

x, y : x*y;

or...

x, y : { //body... }

or the sharp alternative from Brendan [1]

#(x, y) { body... }

I find first option very interesting as it is very tiny for simple lands
lambdas but allowing bigger bodies and with non ambiguous syntax.

[1] http://brendaneich.com/2011/01/harmony-of-my-dreams/
Post by Matthew Robb
I think it's also worth noting that CoffeeScript uses an arrow as well and
it doesn't seem to impact usability much if at all.
- Matthew Robb
On Mon, Sep 22, 2014 at 6:19 PM, Rick Waldron <waldron.rick at gmail.com>
Post by Rick Waldron
On Mon, Sep 22, 2014 at 5:18 PM, Francisco Ferreira <
Post by Francisco Ferreira
Hi,
Just to set some expectations, Although I follow es-discuss, I read more
I have played with dart since it was in alpha. And I also have been
coding with --harmony for a while. I would like to comment that arrow
functions in dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
Sure, but that syntax cannot be used outside of call expression
arguments. I had a proposal in 2011 (
var x = 1;
f = (x)
{ x }
...Which is a valid JavaScript program today, which means that `(params){
body }` cannot parse unambiguously.
Rick
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
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/20140923/7704695e/attachment.html>
Caitlin Potter
2014-09-23 11:19:04 UTC
Permalink
We already have two (three? not sure about JSC) engines which implement arrow functions, plus Traceur. It seems silly to talk about changing the syntax at this point when people have shown they?re already happy with the arrow.

The suggestions shown here, apart from the last item, look pretty ambiguous (and therefore harder to parse). For instance, `x, y : x*y` already looks like a shorthand property + a plain data property with a value computed when the object is instantiated. ` x, y : { // body }` looks like a shorthand property + a data property which happens to be an object literal. I guess the #(x, y) could work, but what?s the point of changing the syntax around again?

Caitlin Potter
caitpotter88 at gmail.com
Post by Salvador de la Puente González
x, y : x*y;
or...
x, y : { //body... }
or the sharp alternative from Brendan [1]
#(x, y) { body... }
I find first option very interesting as it is very tiny for simple lands lambdas but allowing bigger bodies and with non ambiguous syntax.
[1] http://brendaneich.com/2011/01/harmony-of-my-dreams/
I think it's also worth noting that CoffeeScript uses an arrow as well and it doesn't seem to impact usability much if at all.
- Matthew Robb
Hi,
I have played with dart since it was in alpha. And I also have been coding with --harmony for a while. I would like to comment that arrow functions in dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
var x = 1;
f = (x)
{ x }
...Which is a valid JavaScript program today, which means that `(params){ body }` cannot parse unambiguously.
Rick
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
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/20140923/7a22bf2e/attachment-0001.html>
Russell Leggett
2014-09-23 14:09:11 UTC
Permalink
Post by Caitlin Potter
We already have two (three? not sure about JSC) engines which implement
arrow functions, plus Traceur. It seems silly to talk about changing the
syntax at this point when people have shown they?re already happy with the
arrow.
Agreed. This is basically bikeshedding after the bike shed has been built.
Surely there are other areas you could give your attention/feedback to.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140923/88251444/attachment-0001.html>
Salvador de la Puente González
2014-09-23 14:29:41 UTC
Permalink
Yep. I didn't remember shortcut properties.

Anyway, don't worry about discussions. If it's not interesting, it simply
won't go any further. There is always room for improvements.
Post by Caitlin Potter
We already have two (three? not sure about JSC) engines which implement
arrow functions, plus Traceur. It seems silly to talk about changing the
syntax at this point when people have shown they?re already happy with the
arrow.
The suggestions shown here, apart from the last item, look pretty
ambiguous (and therefore harder to parse). For instance, `x, y : x*y`
already looks like a shorthand property + a plain data property with a
value computed when the object is instantiated. ` x, y : { // body }` looks
like a shorthand property + a data property which happens to be an object
literal. I guess the #(x, y) could work, but what?s the point of changing
the syntax around again?
Caitlin Potter
caitpotter88 at gmail.com
On Sep 23, 2014, at 4:30 AM, Salvador de la Puente Gonz?lez <
x, y : x*y;
or...
x, y : { //body... }
or the sharp alternative from Brendan [1]
#(x, y) { body... }
I find first option very interesting as it is very tiny for simple lands
lambdas but allowing bigger bodies and with non ambiguous syntax.
[1] http://brendaneich.com/2011/01/harmony-of-my-dreams/
Post by Matthew Robb
I think it's also worth noting that CoffeeScript uses an arrow as well
and it doesn't seem to impact usability much if at all.
- Matthew Robb
Post by Rick Waldron
On Mon, Sep 22, 2014 at 5:18 PM, Francisco Ferreira <
Post by Francisco Ferreira
Hi,
Just to set some expectations, Although I follow es-discuss, I read
I have played with dart since it was in alpha. And I also have been
coding with --harmony for a while. I would like to comment that arrow
functions in dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
Sure, but that syntax cannot be used outside of call expression
arguments. I had a proposal in 2011 (
var x = 1;
f = (x)
{ x }
...Which is a valid JavaScript program today, which means that
`(params){ body }` cannot parse unambiguously.
Rick
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
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/20140923/f338f379/attachment.html>
John Lenz
2014-10-09 21:12:39 UTC
Permalink
On Tue, Sep 23, 2014 at 4:19 AM, Caitlin Potter <caitpotter88 at gmail.com>
Post by Caitlin Potter
We already have two (three? not sure about JSC) engines which implement
arrow functions, plus Traceur.
And Closure Compilers' ES6 -> ES5 support. :-). (shameless plug)
Post by Caitlin Potter
It seems silly to talk about changing the syntax at this point when people
have shown they?re already happy with the arrow.
The suggestions shown here, apart from the last item, look pretty
ambiguous (and therefore harder to parse). For instance, `x, y : x*y`
already looks like a shorthand property + a plain data property with a
value computed when the object is instantiated. ` x, y : { // body }` looks
like a shorthand property + a data property which happens to be an object
literal. I guess the #(x, y) could work, but what?s the point of changing
the syntax around again?
Caitlin Potter
caitpotter88 at gmail.com
On Sep 23, 2014, at 4:30 AM, Salvador de la Puente Gonz?lez <
x, y : x*y;
or...
x, y : { //body... }
or the sharp alternative from Brendan [1]
#(x, y) { body... }
I find first option very interesting as it is very tiny for simple lands
lambdas but allowing bigger bodies and with non ambiguous syntax.
[1] http://brendaneich.com/2011/01/harmony-of-my-dreams/
Post by Matthew Robb
I think it's also worth noting that CoffeeScript uses an arrow as well
and it doesn't seem to impact usability much if at all.
- Matthew Robb
Post by Rick Waldron
On Mon, Sep 22, 2014 at 5:18 PM, Francisco Ferreira <
Post by Francisco Ferreira
Hi,
Just to set some expectations, Although I follow es-discuss, I read
I have played with dart since it was in alpha. And I also have been
coding with --harmony for a while. I would like to comment that arrow
functions in dart are much better than in ES6 (mozilla implementation).
Let's compare
anObject.thatGetsACallback( (arg1, arg2) => { .... } );
anObject.thatGetsACallback( (arg1, arg2) { .... } );
Sure, but that syntax cannot be used outside of call expression
arguments. I had a proposal in 2011 (
var x = 1;
f = (x)
{ x }
...Which is a valid JavaScript program today, which means that
`(params){ body }` cannot parse unambiguously.
Rick
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
es-discuss mailing list
es-discuss at mozilla.org
https://mail.mozilla.org/listinfo/es-discuss
_______________________________________________
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/20141009/c3a43d66/attachment.html>
Loading...