Allen Wirfs-Brock <mailto:al...@wirfs-brock.com>
January 31, 2012 8:28 AM
On Jan 30, 2012, at 6:38 PM, Brendan Eich wrote:

No! We have a standing agreement to get rid of the awful, lazy-grammar-reuse 
error in ES1 that allows an initializer in for(var x=i in o). We do not want 
this at all for 'let' in either for-in or for-of.

Fine by me, WRT let/const

We haven't done a very good job of capturing such agreements.  I don't think 
this one is reflected on the wiki proposals...

You're right, I thought I'd recorded it. Sorry, fixed:

http://wiki.ecmascript.org/doku.php?id=harmony:iterators#syntax_issues
I think we should break unconditionally and forbid =i in for(var x=i in o) too, 
but that is a separate issue. This botch in grammar factoring is a (bad) sunk 
cost that has zero bearing on the fresh let binding per iteration idea. It's 
terrible anti-precedent. Just say no.

While I think the language would be better without it.  I don't really see how 
we can justify such a breaking change.  Heck, I can even think of a plausible 
use:

function hasEnumerableProperties (obj) {
    for (var key = false in obj);
    return key!==false
}

Yes, unlike 'let' the binding persists after the loop. We can live with this, my hope was that we could also make it an early error and survive because as Arv suggests, it's probably used only in testsuites. But you never know, and the Web tends to tile all executable surfaces and test all features. Let's see how easy it is to split the 'var' and 'let/const' cases...

But you could make a twisted argument for an effect-ful 'let' initialization expression also being "useful" in this way. We mustn't go there.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to