Day 1 meeting notes

Peter van der Zee ecma at qfox.nl
Thu Jul 29 01:20:03 PDT 2010


On Thu, Jul 29, 2010 at 2:06 AM, Waldemar Horwat <waldemar at google.com>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).

- peter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100729/2448cc46/attachment.html>


More information about the es-discuss mailing list