lexical for-in/for-of loose end

Brendan Eich brendan at mozilla.org
Sat Feb 4 11:03:38 PST 2012


Brendan Eich wrote:
>
>   $loopEnd: {
>     let d1 = e1, ... dN = eN;
>     if (cond) {
>       body;
>       update;
>       const $loop = { |d1, ... dN|
>         if (!cond) break $loopEnd;
>         body;
>         update;
>         $loop(d1, ... dN);
>       }
>       $loop(d1, ... dN);
>     }
>   }
>
>
> Notes:
>
> * ... is meta-syntax, not rest/spread syntax.
> * I've left out break and continue in the body.
> * I'm using a block lambda for fun.
>
> Mutations to the first-iteration d1, ... dN bindings in any closures 
> in e1...N propagate to the second iteration.

Another note:

* this is a desugaring, so any of d1...N can be destructuring patterns, 
and with the structuring shorthand for object literals the bindings 
propagate nicely.

Symmetry FTW.

/be


More information about the es-discuss mailing list