Clean scope

Dmitry A. Soshnikov dmitry.soshnikov at
Wed Aug 17 09:13:47 PDT 2011

In case if you don't use free variables, neither `eval` and nor inner 
functions, then implementations (I am sure) provide optimizations not 
capturing parent scope's bindings (at least I know one such an 
implementation -- V8) -- these are your "clean functions". However, 
theoretically, _all_ functions in ECMAScript are closures (except maybe 
those which are created via the `Function` constructor which have only 
global environment as their [[Scope]]). So, no, you can't specify 
explicitly whether or not you need to capture lexical vars.

Info about optimizations:


On 17.08.2011 19:50, John J Barton wrote:
> JavaScript's ability to close over variables in nesting scopes
> sometimes surprises me. I'd like to be able to say "function uses a
> clean scope". Is there something like this in the works? Or maybe it
> exists?
> Thanks,
> jjb
> _______________________________________________
> es-discuss mailing list
> es-discuss at

More information about the es-discuss mailing list