Block lambda grammar: BlockArguments
Brendan Eich
brendan at mozilla.org
Thu Jan 12 23:39:22 PST 2012
> Axel Rauschmayer <mailto:axel at rauschma.de>
> January 12, 2012 11:16 PM
> http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival
>
> I’m trying to understand the syntax:
> BlockArguments :
> BlockLambda
> BlockArguments [no LineTerminator here] BlockLambda
> BlockArguments [no LineTerminator here] ( InitialValue )
>
> - Wouldn’t this allow the following? BlockLambda [no LineTerminator
> here] BlockLambda
Yes.
> - InitialValue means that paren-free can be combined with arguments
> that aren’t blocks, right?
Yes.
>
> myLoopFunc(initValue1)(initValue2) { | arg1, arg2 | ... }
No, the myLoopFunc(initValue1) is a CallExpression -- see
CallWithBlockArguments :
CallExpression [no LineTerminator here] BlockArguments
The *return value* of that ordinary CallExpression is the callee of the paren-free call.
>
> I think I would prefer the following (IIRC, more like Ruby):
>
> myLoopFunc(initValue1, initValue2) { | arg1, arg2 | ... }
>
That parses, as described above. The two-argument CallExpression must
return a function that takes the block arguments.
I see a problem in the grammar in the strawman, now that you mention it:
no way to produce a simple identifier callee from CallExpression, so no
map {|e| e*e}
only
v.map {|e| e*e}
or
get_map() {|e| e*e}
or similar. I will fix.
/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c36c9fe6/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: postbox-contact.jpg
Type: image/jpeg
Size: 1222 bytes
Desc: not available
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20120112/c36c9fe6/attachment-0001.jpg>
More information about the es-discuss
mailing list