Allen Wirfs-Brock (2013-06-14T16:06:35.000Z)
github at esdiscuss.org (2013-07-12T02:27:36.773Z)
On Jun 14, 2013, at 12:01 AM, Andy Wingo wrote: > On Fri 14 Jun 2013 04:24, Luke Hoban <lukeh at microsoft.com> writes: > >> (I believe this introduces the only place that "var x" is allowed but >> cannot have an initializer?). > > FWIW, there are similar situations in the same spot of the grammar: `let x` can't have an initializer in for-of or for-in, and neither can `var x` in for-of. Yes, and this was one of the consistency motivation to the var change. ```js for (const x = c of foo) ... for (const x = c in foo) ... ``` simply woundn't work if x could have an initializer because a const can't be initialized twice. ```js for (let x of foo) ... for (let x in foo) ... ``` with an initializer would suggest that the per iteration binding of x is initialized with the initialization expression. Is the initialization expression evaluated once or at the beginning of each iteration? It is a simpler overall story to just not allow pointless initializers on declarations in for-in/for-of statements. The fact that we could find no dependencies upon for-in var initializers gave us confidence about introduce the breaking change for var.