return when desugaring to closures

Mark S. Miller erights at
Thu Oct 16 13:41:20 PDT 2008

On Wed, Oct 15, 2008 at 4:49 PM, Dave Herman <dherman at> wrote:
> In the grammar for proposed ES4, LetExpression was under
> PrimaryExpression. That's where I'm suggesting LambdaExpression might
> fit. IOW:
> PrimaryExpression ::= ...
>                    |  LetExpression
>                    |  LambdaExpression
> LetExpression ::= "let" "(" LetBindingList ")" CommaExpression
> LambdaExpression ::= "lambda" FunctionSignature LambdaExpressionBody
[quotes inserted above]

As we argue about the pros and cons of this proposed
expression-body-based grammar and similar variations, does anyone see
any problems at all with the following block-based alternative grammar
for them?

  LetExpression ::= "let" ("(" LetBindingList ")")? Block
  LambdaExpression ::= "lambda" FunctionSignature? Block

The only potential advantage I have seen claimed for any of the other
syntaxes over the above block-based syntax is the occasional savings
of two curly brackets -- arguably in exchange for possible confusion.
Are there any other problems with this block-based proposal? If we do
adopt this form of lambda, would there be any remaining need for
non-block functions? Everywhere one might think to write

   function(...) expr

one could just write

    lambda (...) {expr}



More information about the Es-discuss mailing list