[Caja] Open Templates in ES3.1 strict (was: Refactoring out unused material)
On Mon, Jun 16, 2008 at 8:28 PM, Mike Samuel <mikesamuel at gmail.com> wrote:
Is there no way to supply an environment to resolve free variables in textToEval?
Fwiw, is that needed for eval(Template())? My understanding is that, in either case, free variables are pulled from the local scope, which works in the literal Function ctor case.
Ihab
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.
2008/6/16 Mark S. Miller <erights at google.com>:
function works like (new Function (textToEval))(). Is that correct? Is there no way to supply an environment to resolve free variables in textToEval?