lexical for-in/for-of loose end

Brendan Eich brendan at mozilla.org
Tue Jan 31 11:08:26 PST 2012


> Brendan Eich <mailto:brendan at mozilla.org>
> January 31, 2012 10:25 AM
>
>
> So? I wrote "effect" not "scope", now you're defending the unwanted 
> degree of side-effecting freedom? :-|.
>
> One can always make expressions have effects. That's not the point. 
> The reuse of VariableDeclarationNoIn in 12.6.4 without any refactoring 
> or semantic restriction to forbid an initialiser was a mistake. I'm 
> glad to get rid of it, but teasing me will cause endless grumpy fear 
> that it will live on. :-P

So one approach, which Gavin has already tried in WebKit nightlies by 
reserving 'let' unconditionally (so far so good), is to risk breaking 
the web. How about we remove the optional initialiser hiding in for (var 
... in ...); and see what happens?

We may learn quickly that the web depends on this unwanted feature. That 
would be good, it would mean we must restrict 'let' and 'const' in 
for-in and for-of heads from having initialisers. But if we get away 
with it, over this year in nightlies and product builds, then I think we 
should remove the initialiser from the 'var' case too.

/be


More information about the es-discuss mailing list