return when desugaring to closures

Yuh-Ruey Chen maian330 at gmail.com
Sun Oct 12 12:48:10 PDT 2008


Mark S. Miller wrote:
> On Sat, Oct 11, 2008 at 4:33 PM, Dave Herman <dherman at ccs.neu.edu> wrote:
> >
> >    Expression ::= ... | lambda Formals? Statement
> >
>
> Statement or SubStatement? If Statement, what meaning do you propose for
>
> {
>     const f = (lambda () const x = 3;);
>     .... x ....
> }
>
> Does the const export its binding into the lambda's enclosing block,
> such that the x on the next line refers to that x? I hope not.
>
> If the answer is SubStatement, then changing the answer to Block in
> order to require the curlies may very well help people understand the
> scope relationships across the lambda boundary.
>   

Now that I think about it, would it truly be necessary for lambda to
create an implicit block scope in the first place? |lambda() return 10|
would not require such a block scope. Why not have the block scope only
created if there are curly brackets? That would follow the precedent set
by the rest of the language with regards to block scope with the
exception of |for (let x...) ...|.


More information about the Es-discuss mailing list