On Mon, Oct 13, 2008 at 6:34 PM, Brendan Eich <[EMAIL PROTECTED]> wrote: > > On the contrary, what's magical is when one stores i in elements of an > array, or calls setTimeout (example in > https://bugzilla.mozilla.org/show_bug.cgi?id=449811) > , and the results are all the last value of the loop variable. > > This has been a frequent source of confusion and complaints -- a bug, > in short.
Yes, and binding a fresh induction variable on every iteration makes sense for a 'for-each' loop (as in the bug report you cited), where the user is not in charge of updating the induction variable by means of explicit assignment. In a plain 'for' loop, however, it *is* magic if an assignment results in a fresh binding. And it's unexpected magic. Mark said that there was a desugaring for 'for' to 'lambda,' without special cases, where this all works out, but I haven't been able to figure out what rewrite he had in mind. > > Doing it the way Mark proposes fixes the bug, and has no other bad > effects that I can see (but we'll have to implement and user-test to > be sure). Turning an assignment into a non-assignment is bad. > >> I could be convinced, though -- do you want to try and make the case >> for >> why there should be a fresh variable per iteration with some concrete >> examples? > > https://bugzilla.mozilla.org/show_bug.cgi?id=449811 Like I said, it makes sense for 'for-each.' -Jon _______________________________________________ Es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

