Questions re. final fat arrow syntax

Brendan Eich brendan at mozilla.org
Mon Apr 9 08:33:52 PDT 2012


Axel Rauschmayer wrote:
>> As I've said a couple of times here, we could try again to reach 
>> consensus on making () as empty arrow formal parameter list optional,
>
> Seems useful, but not worth upsetting anyone over.

The issue may not be undiagnosed upset-ness, rather ASI.

Leaving out () in front of => in a language such as CoffeeScript, which 
has significant newlines, is easier than making the empty arrow formal 
parameters optional in JS. True, a parenthesized expression statement 
usually won't be mistaken for a parameter list, and an arrow usually 
won't start a statement.

But code generators and machine or human editors might manage to produce

   ( a, b )
   => c
   ( d );

I'm not very worried about this biting anyone, but it's a potential 
objection and one I suspect blenching TC39ers near me would make.

>> and separately consider making an empty body-block optional.
>
> Sorry if I missed this, but: What would this be used for?

Just a short-hand for returning undefined, for a stub function.

/be


More information about the es-discuss mailing list