block lambda revival

Brendan Eich brendan at mozilla.com
Tue May 24 22:38:13 PDT 2011


On May 24, 2011, at 7:20 PM, Jon Zeppieri wrote:

> On Tue, May 24, 2011 at 3:29 PM, Brendan Eich <brendan at mozilla.com> wrote:
>> 
>> 
>> BlockArguments :
>>    BlockLambda
>>    BlockArguments [no LineTerminator here] BlockLambda
>>    BlockArguments [no LineTerminator here] ( Expression )
>> 
> 
> The interleaved parenthesized expression worries me for two reasons:
> 
> - Waldemar's "currying hazard" doesn't strike me so much as a hazard
> as it does expected behavior. But that might just be me.

It's probably damned-if-you-do-or-don't, hence the desire to cage CallWithBlockArguments inside parentheses in most cases.


> - If the the parenthesized expression is a comma expression, e.g.,
> 
>   f{|x| x}(a, b, c)
> 
> I might expect a, b, and c to be spliced into the arguments list,
> whereas, given the formal grammar, I assume a and b will be evaluated
> for side-effects, and c will be the argument.

Yes, that's a good point.

And your examples caused me to reflect, I realized that I maladroitly failed to close the loop with InitialValue, which can be AssignmentExpression (next loosest after [comma] Expression) or CallWithBlockArguments. We want arguments and other initial values to use InitialValue.

In other words, we should support

  foo {|...| ...} (bar {|...| ...})

without requiring doubled parentheses around the last actual.

So revising to this:

ElementList :                               // See 11.1.4
    Elisionopt InitialValue
    ElementList , Elisionopt InitialValue

PropertyAssignment :                        // See 11.1.5
    PropertyName : InitialValue

ArgumentList :                              // See 11.2
    InitialValue
    ArgumentList , InitialValue

Initialiser :                               // See 12.2
    = InitialValue

InitialiserNoIn :                           // See 12.2
    = InitialValueNoIn

InitialValue :
    AssignmentExpression
    CallWithBlockArguments

Statement :
    ...
    CallWithBlockArguments
    LeftHandSideExpression = CallWithBlockArguments
    LeftHandSideExpression AssignmentOperator CallWithBlockArguments

PrimaryExpression :
    ...
    ( CallWithBlockArguments )

CallWithBlockArguments :
    MemberExpression [no LineTerminator here] BlockArguments

BlockArguments :
    BlockLambda
    BlockArguments [no LineTerminator here] BlockLambda
    BlockArguments [no LineTerminator here] ( InitialValue )

BlockLambda :
    { | BlockParameterListopt | StatementListopt }

BlockParameterList :
    BlockParameter
    BlockParameterList , BlockParameter

BlockParameter :
    Identifier BlockParameterInitialiseropt
    Pattern BlockParameterInitialiseropt

BlockParameterInitialiser :
    = BitwiseXorExpression

Thanks,

/be
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110524/260a87f8/attachment.html>


More information about the es-discuss mailing list