The nicest proposal I have seen has been written by David Herman:
https://gist.github.com/2011902

Commenting on the gist proposals:

G1. shorter function syntax: (..) -> {..} just sugar for function (..) {..}

This looks like a strawman, not solving the issues.

G2. lambdas:    (..) => expr

   expression-oriented (no statement blocks, no explicit returns),
   implicit return, no 'this'

This looks like the familiar construct from FPLs. I'd like to have
it (possibly with 'fn' prefix for easier parsing) but, on its own, it
might not address all JS-specific concerns, which calls for a
combination with statement block oriented construct.

G3. do expressions:    do {..}

   evaluate statement block for completion value, block with
   implicit return,  decouples explicit from implicit returns

This looks deceptively simple, but the combination of G2 and
block lambdas seems to be equivalent to the combination of
G2 and do expressions:

   do {..}     maps to     {||..}()
   {|..| ..}     maps to     (..) => do {..}

That would mean that more or less the same pros and cons
apply to both combinations.

Claus


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

Reply via email to