block lambda revival

Brendan Eich brendan at mozilla.com
Mon May 23 18:51:30 PDT 2011


On May 23, 2011, at 6:29 PM, Brendan Eich wrote:

> On May 23, 2011, at 6:27 PM, Waldemar Horwat wrote:
> 
>> On 05/23/11 18:09, Brendan Eich wrote:
>>> Here are some ideas:
>>> 
>>> 1. Extend the current proposal to allow parenthesized expressions interleaved with no line terminators, only optional horizontal space characters, with block-lambda expressions:
>>> 
>>> bar = foo {|x| x * x} (42);
>> 
>> That might work, with the key part being "interleaved".  We need to keep the semantics of
>> 
>> bar = foo(42)(33);
>> 
>> the same as now.
> 
> Absolutely.
> 
> I'll make an attempt, since option 0 (see later mail) is both easy and a bit of a hasty surrender.

Done, at http://wiki.ecmascript.org/doku.php?id=strawman:block_lambda_revival -- this was easy, but it made me wonder whether parentheses for the plain Expression arguments that may occur after the leading BlockLambda ought not better be curly braces. IOW, instead of

  bar = foo {|x| x * x} (42);

support this:

  bar = foo {|x| x * x} {42};

This is more uniform on its own new terms. If the first actual parameter wants to be an expression, the programmer must parenthesize the entire argument list (comma separated of course), or else write {| | 42} as the first argument.

So, are curlies better than parens in this situation? I think it is a bit of a corner case, but good to address to avoid the currying hazard.

/be

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110523/685c65f1/attachment.html>


More information about the es-discuss mailing list