transparent lambda

John Rose John.Rose at Sun.COM
Thu Jan 7 01:39:21 PST 2010


On Jan 7, 2010, at 12:13 AM, Neal Gafter wrote:

>> With no need for parens in most places, especially argument and initializer expressions:
> 
> Without the parens it is ambiguous with a labelled statement.

Actually, I think it's better to regard it as the *same* syntax in both places.

> I think
> we should minimize the number of distinct syntactic forms rather than
> handling different contexts differently.

That is, as a form considered in isolation, a labeled block is the same syntax, whether or not it is going to produce a value.  The rules about whether a given block is allowed to produce a value are semantic checks done after parsing.

But there will have to be some careful distinction made between a non-value-bearing block followed by an expression and a value-bearing block combined into an expression with a following sub-expression, and that may make it too difficult to use plain blocks.  It's a pity, because a labeled block is familiar looking and not too noisy.

Would it be enough to say that a statement expression will not begin with a labeled block?  This could be enforced by adjusting the grammar, or by adding a syntax constraint on top of the expression-statement nonterminal.

-- John


More information about the closures-dev mailing list