lexical for-in/for-of loose end

Brendan Eich brendan at mozilla.org
Mon Feb 6 07:28:57 PST 2012


Andreas Rossberg wrote:
> On 4 February 2012 21:55, Brendan Eich<brendan at mozilla.org>  wrote:
>> >  The argument is as follows:
>> >
>> >    for (let i = 0, a = some.array, n = a.length; i<  n; i++) { ... }
>> >
>> >  here we definitely want the a in a.length (n's initializer) to be scoped by
>> >  the head let -- to be the a declared by the second declarator.
>> >
>> >  Now consider a bit of eta conversion:
>> >
>> >    for (let i = 0, a = some.array, n = (function(){return a})().length; i<  n;
>> >  i++) { ... }
>
> Nit: That is a beta-conversion, not an eta-conversion.;-)
> (Fortunately, because eta-conversions are not actually
> semantics-preserving in an impure language.)

(B-key was sticky :-P)

Thanks...


>> >  I claim implementation is not the driver here. User expectations, esp. savvy
>> >  users who might make some practical or theoretical (testing) use of [beta]
>> >  conversion, matter more.
>
> Agreed. As long as we don't spec something weird, the extra effort for
> implementations shouldn't be much more than that of an extra block
> around the loop body.

To take Allen's best shot and re-fire it, what do you think should 
happen here?

   for (let i = 0, skip2 = function(){i++}; i < N; i++) {
     foo();
     if (bar())
       skip2();
   }

/be


More information about the es-discuss mailing list