return when desugaring to closures
David-Sarah Hopwood
david.hopwood at industrial-designers.co.uk
Mon Oct 13 16:51:05 PDT 2008
David-Sarah Hopwood wrote:
> Mark S. Miller wrote:
>> [...] I recommend the per-iteration view. If we can
>> agree quickly on per-iteration, then
>>
>> for (const x = ...) {...x...}
>>
>> should be allowed in ES3.1 (whether or not const hoists to block
>> start). After ES3.1
>>
>> for (const i :T[i] = ...) {...; a[i] = function(){...i...}; ...}
>>
>> would then mean what it should mean. Cool.
>
> Not so fast :-) Consider:
>
> for (let i = 0; i < 10; i++) { ... }
>
> In the "i++", which iteration's 'i' is the LeftHandSideExpression
> referring to? Or does this expand to something like:
>
> let ($i = 0) {
> for (;
> let (i = $i) {i < 10};
> let (i = $i) {{i++;} $i = i;}} {
> let (i = $i) {...};
> }
> }
>
> ?
This expansion is wrong for the case where the body updates i.
I'll have to think about it some more.
--
David-Sarah Hopwood
More information about the Es-discuss
mailing list