return when desugaring to closures
David-Sarah Hopwood
david.hopwood at industrial-designers.co.uk
Sat Oct 11 07:12:04 PDT 2008
Yuh-Ruey Chen wrote:
> David Herman wrote:
>>> My question was whether the semantics of break and continue would
>>> support the following:
>> Yes, this is another good case to consider. Thanks for pointing it out;
>> I'll add this to the strawman:lambdas proposal. Essentially this is
>> another aspect of the semantics of 'function' that is implicit -- that
>> it cancels out the scope of break/continue labels -- and it's precisely
>> these implicit elements of a language feature that break expected
>> equivalences. (They are essentially "unhygienic" -- if you push me, I
>> can explain the connection to macros.)
Consider yourself pushed.
> First off, I'm really glad that "clean" functions are being considered
> for ES-Harmony - another step toward hygienic macros!
>
> 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).
--
David-Sarah Hopwood
More information about the Es-discuss
mailing list