Allen Wirfs-Brock (2014-06-16T19:01:08.000Z)
On Jun 16, 2014, at 11:29 AM, Michael Zhou wrote:

> Thanks for the clarification, one detail about the order between incrementing and setting $$lastIteration_i:
> {
>    let i = $$lastIteration_i;   //create and initialize per iteration i
>    if (!(i<10)) break;
>   {
>       let i;
>    }
>    i++;
>    $$lastIteration_i = i;
> }
> 
> Should it be
> $$lastIteration_i = i;
> i++;
> 
> instead, given what the spec says?
neither of these desugarings is perfectly in alignment with the actual spec. which doesn't actually use a temp variable in this manner.

A closer match would be:

$$lastIteration_i = i;
$$lastIteration_i++;

The value of the new i for the next iteration is the incremented value of the previous i, but the value of the previous i is not incremented which is important for the cases where a closure has captured the previous i.

Allen



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140616/7ebea9f8/attachment.html>
domenic at domenicdenicola.com (2014-06-19T20:55:13.745Z)
neither of these desugarings is perfectly in alignment with the actual spec. which doesn't actually use a temp variable in this manner.

A closer match would be:

```js
$$lastIteration_i = i;
$$lastIteration_i++;
```

The value of the new `i` for the next iteration is the incremented value of the previous `i`, but the value of the previous `i` is not incremented which is important for the cases where a closure has captured the previous `i`.