Desugaring "for" and "let"

Brendan Eich brendan at mozilla.com
Mon Jul 11 09:41:14 PDT 2011


On Jul 11, 2011, at 7:18 AM, Axel Rauschmayer wrote:

> I remember that this has been previously discussed, but can't find the thread. For me, the above desugaring is easier to understand than the lambda coding.

Just recently:

https://mail.mozilla.org/pipermail/es-discuss/2011-June/015615.html (thread head)

and previously:

https://mail.mozilla.org/pipermail/es-discuss/2008-October/007826.html



> Compare: With Java, you have to declare
>    final int finalI = i;
> inside a for loop if you want to refer to i from an inner class.

Yeah, but that sucks so let's not cite it as any kind of precedent :-|.

Anyway, for-in and for-of with let give fresh binding per iteration -- that's the plan for ES.next.

Ye olde C-style for(init; cond; update) {...} loops are thin veneer for init; while (cond) {... update}, and as Jon Z. pointed out, since you can take them apart accordingly, the binding semantics should not shift as you do.

/be


More information about the es-discuss mailing list