On Jul 29, 2010, at 1:20 AM, Peter van der Zee wrote: > On Thu, Jul 29, 2010 at 2:06 AM, Waldemar Horwat <[email protected]> wrote: > Error prone: for (x in Iterator.values([1,2,3,4,5])) vs. likely > programming error for (x in [1,2,3,4,5]) > > Waldemar: If they are separate concepts, using the same for-in syntax > for iteration and enumeration is too error-prone. If you intend to > iterate on object Foo but accidentally pass in a Foo that's not an > iterator, you'll get its property names instead of a visible error. > It's particularly insidious with arrays. > > Would a keyword "as" be a sufficient alternative to use as an iteration > operator in this sense? "as" would (I think?) not be allowed as an identifier > in that position so it wouldn't have to be added to the reserved word lists. > Because of that, I don't see a parser problem with it either. > > Maybe, for somewhat better semantics, the order could be switched (`iterator > as key` would make slightly better sense compared to `key as iterator`. I'm > okay with either way since the switch would mean slightly more complicated > syntax, eg. the var statement).
The whole "fatal flaw" claim is Waldemar's opinion, but we've shipped for-in with (unstratified) meta-programmability since 2006 (Firefox 2) and Python has had it for years. Where are all the corpses? /be
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

