return when desugaring to closures

Peter Michaux petermichaux at gmail.com
Sat Oct 11 09:05:01 PDT 2008


On Sat, Oct 11, 2008 at 7:12 AM, David-Sarah Hopwood
<david.hopwood at industrial-designers.co.uk> wrote:
> Yuh-Ruey Chen wrote:

>> I read through the strawman:lambdas proposal and saw that it did not
>> mention anything about |var|, e.g.
>>
>> (function() {
>>     lambda {
>>        var x = 10;
>>     }();
>>     return x;
>> })()
>>
>> Does the |var| within the lambda define a var in the function body, and
>> does that var declaration hoist to the top of the function body?
>
> To satisfy Tennent's correspondence, all var statements must hoist in the
> same way ignoring lambdas -- i.e. to the top of the innermost enclosing
> function body (if not in the global scope).

How to define a variable that is local to the enclosing lambda? Isn't
the ability to do that essential?

Peter


More information about the Es-discuss mailing list