return when desugaring to closures
Dave Herman
dherman at ccs.neu.edu
Wed Oct 15 12:31:18 PDT 2008
> Please specify what you are proposing. The one proposal I've seen is:
>
> Expression ::= ... | lambda Formals Statement
Yes, that's what I meant, or at least what I thought Yuh-Ruey meant.
> This is not particularly useful because then even assign a lambda to a
> variable would be a syntax error,
Why is that?
> and you'd introduce a bizarre asymmetry into the ExpressionNoIn case.
Can you explain?
> The questions you'd have to answer are:
>
> - Where in the expression grammar would you introduce a lambda?
I assume you mean what is the precedence. I'm not sure, although
presumably it would be about the same as `let' expressions.
> - Is lambda a reserved word?
This is a relevant question for any number of alternative syntaxes for
lambda. I would think it would be the same as `let'.
> - How does it interact with semicolon insertion? As written, if the
> Statement were an expression statement then the semicolon would be
> mandatory.
Why is that? If that were so then I would be absolutely opposed to
Yuh-Ruey's syntax: the appeal of the idea was unifying the
expression-body and statement-body form into one single definition.
> - 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++;) ...
Thanks, these were the kinds of nastinesses I was worried about.
Arbitrarily mixing statements into expression contexts does indeed
appear to get pretty convoluted. Perhaps just enforcing the block form
of lambda is enough to keep things from getting too mixed up,
specifically, by enforcing syntactic delimiters between expressions.
> Overall, this syntax does not look promising. It's likely to get you
> into complexity trouble.
Do you prefer (lambda Formals Block | lambda Formals Expression)?
[Personally I'm fine with that.] Or do you oppose any lambda expressions
at all? Or did you have something else in mind?
Thanks,
Dave
More information about the Es-discuss
mailing list