[Caja] Open Templates in ES3.1 strict (was: Refactoring out unused material)

Brendan Eich brendan at mozilla.org
Mon Jun 16 23:04:38 PDT 2008

On Jun 16, 2008, at 8:28 PM, Mike Samuel wrote:

> From my reading of ES4, the eval operator works that way, and the  
> eval function works like (new Function (textToEval))().  Is that  
> correct?

The latter (eval function, called indirectly, e.g.) is detectably  
different: var bindings at top level in the textToEval do not persist  
in the global object, but make local variables in the new Function.

> Is there no way to supply an environment to resolve free variables  
> in textToEval?

The usual way to do this is to wrap the eval call in a function whose  
arguments name the free variable, and return the result. The usual  
shared prototype and global mutation hazard warnings apply, but any  
var bindings in the program will be confined.


More information about the Es4-discuss mailing list