For Loop Desugaring (was: return when desugaring to closures)

Jon Zeppieri jaz at bu.edu
Tue Oct 14 08:14:48 PDT 2008


On Tue, Oct 14, 2008 at 2:38 AM, Jon Zeppieri <jaz at bu.edu> wrote:
> On Mon, Oct 13, 2008 at 10:48 PM, Mark S. Miller <erights at google.com> wrote:
>>
>> I believe this meets all your requirements.
>
> I believe it does.  Very cool.  It won't handle the fully general
> for(;;).  E.g.,
>
> for (let fn = lambda(n) { ... fn(...) ... }; <testExpr>; <updateExpr>) ...
>
> Also,
>
> for (let i = 0, j = i + 1; ...) ...
>
> But the modifications needed to make these work are pretty straightforward.
>

And then there are the batshit crazy cases.  This was inspired by Dave
Herman's latest blog post
(http://calculist.blogspot.com/2008/10/todays-javascript-kookiness.html):

    var arr = [];

    for (eval("let x = 10;"); x >= 0; x--)
        arr.push(x);

    alert(arr);


Works (for some value of "works") in JS1.7.

-Jon


More information about the Es-discuss mailing list