lexical for-in/for-of loose end

Brendan Eich brendan at mozilla.org
Mon Feb 6 07:37:34 PST 2012


Andreas Rossberg wrote:
> On 4 February 2012 18:49, Brendan Eich<brendan at mozilla.org>  wrote:
> In other words, why isn't the following good enough?
>
> {
>   let d1 = e1, ..., dN = eN;
>   const $loop = {|d1, ..., dN|
>     if (cond) {
>       body
>       update;
>       $loop(d1, ..., dN);
>     }
>   }
>   $loop(d1, ..., dN);
> }

This is the "0th iteration scope" idea. It's good enough if (a) we want 
skip2 (see last post) affecting no iteration's loop variables, and (b) 
we can take the extra scope cost-hit.

> FWIW, this is simply the generalization of Mark's desugaring so that
> it works with destructuring, multiple bindings, and recursive
> bindings. Plus, it removes the redundant second lambda in his version.

It's fine if we like (a) on usability grounds, and (b) is true for all 
implementors and wtf-benchmarketing kooks.

I argued vigorously for 1st-iteration rather than 0th-iteration scope 
but that was to say "no" to (b). I'm actually not sure what skip2-coding 
authors will want -- probably an error as Allen suggests. But let's say 
yes to (a) -- I can live with (b) absent further evidence.

The issue remains (a). Allen's best shot is the skip2 scenario (advance 
in his post). What's the right outcome for users who write such code?

/be


More information about the es-discuss mailing list