Block lambda grammar: BlockArguments

Axel Rauschmayer axel at rauschma.de
Fri Jan 13 21:09:17 PST 2012


> Fixed: http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival&do=diff
> 
> The LeftHandSideExpression productions and their kids (NewExpression and CallExpression) are funky and I keep misremembering how NewExpression is what bottoms out via MemberExpression -> PrimaryExpression at Identifier.


If I read the grammar correctly, then you can do things such as (read "~~~>" as "desugars to"):

     myfunc {|| } {|| } (arg3) (arg4)  ~~~>  myfunc({|| }, {|| }, arg3, arg4)

The above is a function call with 4 arguments. My wish would be different: I would want to put lambdas after a function or method call and treat those lambdas as additional arguments:

     myfunc(arg1, arg2) {|| } {|| }  ~~~>  myfunc(arg1, arg2, {|| }, {|| })
     myfunc {|| } {|| }  ~~~>  myfunc({|| }, {|| })

Rationale: I would always make lambdas trailing arguments, similar to
     if (cond) {} {}
And I would rather achieve this effect without currying. Following a block with a non-block doesn’t seem like a good idea.

Has the other approach been considered?

-- 
Dr. Axel Rauschmayer
axel at rauschma.de

home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120114/6853d702/attachment.html>


More information about the es-discuss mailing list