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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to