lexical for-in/for-of loose end

Allen Wirfs-Brock allen at wirfs-brock.com
Sat Feb 4 08:52:36 PST 2012


On Feb 4, 2012, at 6:02 AM, Jason Orendorff wrote:

> On Fri, Feb 3, 2012 at 7:26 PM, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>> On Feb 3, 2012, at 4:26 PM, Jason Orendorff wrote:
>>> On 2/3/12 6:13 PM, Allen Wirfs-Brock wrote:
>>>> But I also have to validly (and hopefully reasonably) specify exactly what happens for the unrealistic use cases. There is a problem with your desugaring in that the evaluation of INIT isn't scoped correctly relative to V.
>>> Hmmm. I don't see the problem yet. I think it's scoped the way I intended it: INIT is evaluated in the enclosing environment; V isn't in scope.
>> 
>> Under the scoping rules TC39 has agreed to, the initializer of a let/const is always shadowed by the binding it is initializing[...]
> 
> That rule doesn't make sense in this context. There should be either
> one V for the whole loop, or one V per iteration. Having both seems
> perverse.

I agree, but having both is exactly what for(let;;) requires in order to satisfy (actually approach satisfying) everybody.  If you want the simplicity of the either or alternative then a good approach seems to be that  for-in/for-of is one per iteration and for(;;) is one for the whole loop. C# recently when though a similar design change and that is exactly where they ended up.

Allen



More information about the es-discuss mailing list