Hm, that's an interesting point: *all* declaration forms are sensitive to being wrapped in a function, e.g.:
|(function() { var x })()| != |var x| That pretty much nixes that critique! Dave On Nov 23, 2010, at 9:53 AM, Allen Wirfs-Brock wrote: > How is your example any different from if you had said: > const foo=1; > > In both cases, wrapping the declaration with a function changes its scope?? > > Allen > > -----Original Message----- From: David Herman > Sent: Tuesday, November 23, 2010 9:24 AM > To: Dmitry A. Soshnikov > Cc: es-discuss@mozilla.org > Subject: Re: `static` keyword from C/C++ as own closured var declaration > >> Can you give a small example (it's just interesting) -- to see the issue? > > Sure thing. Say you're writing some code with a constant value, and somewhere > inside the code you use `static': > > var METERS_PER_SQUARE_KILOJOULE = 17.4; > ... > static foo = 1; > ... > f(foo, METERS_PER_SQUARE_KILOJOULE); > > Now you decide you want to parameterize over the constant, instead of a fixed > constant: > > function(metersPerSquareKiloJoule) { > ... > static foo = 1; > ... > f(foo, metersPerSquareKiloJoule); > } > > This change accidentally alters the scope of `foo'. > > Dave > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss _______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss