Andreas Rossberg (2014-06-05T14:58:07.000Z)
domenic at domenicdenicola.com (2014-06-10T19:05:29.392Z)
C-style for-loops allow declarations as init statements, but only some of them. Yet, the others (function and class) are actually syntactically legal in that position as well, because they are simply parsed as expressions. Consider: ```js let x = 0 for (let x = 1; ;) x // 1 for (const x = 1; ;) x // 1 for (function x(){}; ;) x // 0 for (class x(){}; ;) x // 0 ``` I think these latter two examples violate the principle of least surprise. I wonder if it wouldn't be cleaner to rule them out, by imposing the same lookahead restrictions on for-loop init expressions as there are for expression statements. The one caveat is that for function, that would actually be a breaking change, but is it likely to be a real world one? What do you think?