return when desugaring to closures
waldemar at google.com
Mon Oct 13 17:19:31 PDT 2008
David Herman wrote:
>> Also, I wonder why lambda in it's block-less form is restricted to
> I'm with you... but I'd want to check with the experts on the ES grammar to see whether this introduces any nasty ambiguities.
Please specify what you are proposing. The one proposal I've seen is:
Expression ::= ... | lambda Formals Statement
This is not particularly useful because then even assign a lambda to a variable would be a syntax error, and you'd introduce a bizarre asymmetry into the ExpressionNoIn case.
The questions you'd have to answer are:
- Where in the expression grammar would you introduce a lambda?
- Is lambda a reserved word?
- How does it interact with semicolon insertion? As written, if the Statement were an expression statement then the semicolon would be mandatory.
- Do you really want to have extra semicolons in the middle of statements? Now you're forced to accept things like the following:
for (; lambda() x++;, lambda() y++;,; lambda() z++;) ...
Overall, this syntax does not look promising. It's likely to get you into complexity trouble.
More information about the Es-discuss